diff --git a/base/Base.jl b/base/Base.jl index 3a3d095d3916c..42a506479326b 100644 --- a/base/Base.jl +++ b/base/Base.jl @@ -488,7 +488,6 @@ function __init__() if haskey(ENV, "JULIA_MAX_NUM_PRECOMPILE_FILES") MAX_NUM_PRECOMPILE_FILES[] = parse(Int, ENV["JULIA_MAX_NUM_PRECOMPILE_FILES"]) end - append!(empty!(TIMING_IMPORTS), zeros(Int, Threads.nthreads())) nothing end diff --git a/base/loading.jl b/base/loading.jl index 238ab4b84de58..eac5286263690 100644 --- a/base/loading.jl +++ b/base/loading.jl @@ -822,7 +822,7 @@ function _require_from_serialized(path::String) end # use an Int counter so that nested @time_imports calls all remain open -const TIMING_IMPORTS = Int[] # initialized in __init__ +const TIMING_IMPORTS = Threads.Atomic{Int}(0) # returns `true` if require found a precompile cache for this sourcepath, but couldn't load it # returns `false` if the module isn't known to be precompilable @@ -859,7 +859,7 @@ function _require_search_from_serialized(pkg::PkgId, sourcepath::String, depth:: if isa(restored, Exception) @debug "Deserialization checks failed while attempting to load cache from $path_to_try" exception=restored else - if TIMING_IMPORTS[Threads.threadid()] > 0 + if TIMING_IMPORTS[] > 0 elapsed = round((time_ns() - t_before) / 1e6, digits = 1) tree_prefix = depth == 0 ? "" : "$(" "^(depth-1))┌ " print("$(lpad(elapsed, 9)) ms ") diff --git a/stdlib/InteractiveUtils/src/macros.jl b/stdlib/InteractiveUtils/src/macros.jl index 17b9943d88165..701f548e9da91 100644 --- a/stdlib/InteractiveUtils/src/macros.jl +++ b/stdlib/InteractiveUtils/src/macros.jl @@ -235,10 +235,10 @@ end macro time_imports(ex) quote try - Base.TIMING_IMPORTS[Threads.threadid()] += 1 + Base.TIMING_IMPORTS[] += 1 $(esc(ex)) finally - Base.TIMING_IMPORTS[Threads.threadid()] -= 1 + Base.TIMING_IMPORTS[] -= 1 end end end