diff --git a/docs/src/config.md b/docs/src/config.md index c99796ad..f4a94821 100644 --- a/docs/src/config.md +++ b/docs/src/config.md @@ -122,6 +122,24 @@ string `"1"` (e.g., `JULIA_REVISE_INCLUDE=1` in a bash script). Most users should avoid setting `JULIA_REVISE_INCLUDE`. Try `includet` instead. +### Enabling struct revision + +On Julia 1.12+, Revise can automatically revise `struct` definitions in a +running session. This feature requires scanning the global method table and +type hierarchy at startup, which can be slow so it's disabled by default. If you +would like to enable it you can set the `revise_structs` preference to `true` +via [Preferences.jl](https://github.com/JuliaPackaging/Preferences.jl). + +Add the following to the `LocalPreferences.toml` file in your active project: + +```toml +[Revise] +revise_structs = true +``` + +!!! warning + The default for this preference may change in the future. + ## Configurations for fixing errors ### No space left on device @@ -158,7 +176,7 @@ $ sudo sysctl fs.inotify.max_user_instances=2048 ``` After changing these values, it is advised to run Revise's unit tests to see if they pass. -This change can be made [permanent](https://www.suse.com/de-de/support/kb/doc/?id=000020048). +This change can be made [permanent](https://support.scc.suse.com/s/kb/360054835111). For more information see issues [#26](https://github.com/timholy/Revise.jl/issues/26) and [#778](https://github.com/timholy/Revise.jl/issues/778). diff --git a/docs/src/index.md b/docs/src/index.md index 465db06c..1b367f92 100644 --- a/docs/src/index.md +++ b/docs/src/index.md @@ -184,7 +184,7 @@ end To make it easier for other packages to benefit from Revise without needing to add it as a dependency or understand Revise's internals, Revise interfaces with -[CodeTracking](https://github.com/timholy/CodeTracking.jl), +[CodeTracking](https://github.com/JuliaDebug/CodeTracking.jl), which is a small package acting as Revise's "query" interface. ## What else do I need to know? diff --git a/src/lowered.jl b/src/lowered.jl index 66120dca..2d270176 100644 --- a/src/lowered.jl +++ b/src/lowered.jl @@ -436,7 +436,7 @@ function _methods_by_execution!( callstmt = stmt @label call_dispatch f = lookup(frame, callstmt.args[1]) - if __bpart__ && f === Core._typebody! + if __bpart__[] && f === Core._typebody! analyze_typebody!(exinfo, interp, frame, callstmt) pc = step_expr!(interp, frame, stmt, true) elseif is_defaultctors(f) && length(callstmt.args) == 3 diff --git a/src/packagedef.jl b/src/packagedef.jl index 87f3ebd0..28dade24 100644 --- a/src/packagedef.jl +++ b/src/packagedef.jl @@ -153,8 +153,9 @@ Global variable, maps `(pkgdata, filename)` pairs that errored upon last revisio """ const queue_errors = Dict{Tuple{PkgData,String},Tuple{Exception, Any}}() # locking is covered by revision_queue_lock -# Can we revise types? -const __bpart__ = Base.VERSION >= v"1.12.0-DEV.2047" +# Can we revise types? This is assigned in __init__() based on the Julia version +# and preference. +const __bpart__ = Ref(false) """ Revise.NOPACKAGE @@ -343,7 +344,7 @@ function delete_missing!( for exinfo in exinfos if exinfo isa SigInfo handle_method_deletion!(exinfo, rex, world) - elseif __bpart__ + elseif __bpart__[] handle_type_deletion!(exinfo::TypeInfo, reeval_list, handled_types, world) end end @@ -1006,7 +1007,7 @@ function revise(; throw::Bool=false) end # Do binding redefinitions - if __bpart__ + if __bpart__[] redefine_bindings!(revision_errors, reeval_list, world) end @@ -1594,6 +1595,7 @@ function __init__() for pkg in silenced push!(silence_pkgs, pkg) end + __bpart__[] = Base.VERSION >= v"1.12.0-DEV.2047" && Preferences.@load_preference("revise_structs", false) polling = get(ENV, "JULIA_REVISE_POLL", "0") if polling == "1" polling_files[] = watching_files[] = true @@ -1663,7 +1665,7 @@ function __init__() # This feature needs to be disabled on Apple Silicon for Julia v1.12 and earlier # due to the Julia runtime side issue (https://github.com/JuliaLang/julia/issues/60721) @static if !(VERSION < v"1.13-" && Sys.isapple()) - if __bpart__ && (isnothing(distributed_module) || distributed_module.myid() == 1) + if __bpart__[] && (isnothing(distributed_module) || distributed_module.myid() == 1) Threads.@spawn :default foreach_subtype(Any) do @nospecialize type # Populating this cache can be time consuming (eg, 30s on an # i7-7700HQ) so do this incrementally and yield() to the scheduler diff --git a/test/runtests.jl b/test/runtests.jl index 4da3bbed..51425dd5 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -2467,7 +2467,7 @@ end pop!(LOAD_PATH) end - Revise.__bpart__ && do_test("Type info tracking") && @testset "Type info tracking" begin + Revise.__bpart__[] && do_test("Type info tracking") && @testset "Type info tracking" begin let exinfo = lower_and_track(:(abstract type ABC end)) typeinfo = only(exinfo.typeinfos) @test typeinfo.typname == @invokelatest(getglobal(TypeInfoTracking, :ABC)).name @@ -2529,9 +2529,9 @@ end end end - Revise.__bpart__ && do_test("visit") && @testset "visit" include("test_visit.jl") + Revise.__bpart__[] && do_test("visit") && @testset "visit" include("test_visit.jl") - if Revise.__bpart__ && do_test("struct revision (simple)") # can we revise types and constants? + if Revise.__bpart__[] && do_test("struct revision (simple)") # can we revise types and constants? @testset "struct revision (simple)" begin testdir = newtestdir() try @@ -2566,7 +2566,7 @@ end end end - if Revise.__bpart__ && do_test("struct revision (retry)") + if Revise.__bpart__[] && do_test("struct revision (retry)") @testset "struct revision (retry)" begin testdir = newtestdir() try @@ -2617,7 +2617,7 @@ end end end - if Revise.__bpart__ && do_test("struct revision (dependency)") # can we revise types and constants? + if Revise.__bpart__[] && do_test("struct revision (dependency)") # can we revise types and constants? @testset "struct revision (dependency)" begin testdir = newtestdir() try