From ed2d0d1fd10f1005d8fac17cd3bd768216e02d73 Mon Sep 17 00:00:00 2001 From: Jameson Nash Date: Sat, 15 Jan 2022 10:01:59 -0500 Subject: [PATCH] Revert "Profile: Faster data dict lookup (#43805)" (#43814) --- stdlib/Profile/src/Profile.jl | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/stdlib/Profile/src/Profile.jl b/stdlib/Profile/src/Profile.jl index 63b70cc9b16c01..3409e79bdb128f 100644 --- a/stdlib/Profile/src/Profile.jl +++ b/stdlib/Profile/src/Profile.jl @@ -349,18 +349,15 @@ function getdict(data::Vector{UInt}) end function getdict!(dict::LineInfoDict, data::Vector{UInt}) - # we don't want metadata here as we're just looking up ips - unique_data_itr = Iterators.unique(has_meta(data) ? strip_meta(data) : data) - foreach(ip -> dict[UInt64(ip)] = StackFrame[], unique_data_itr) - @sync for ip in unique_data_itr - Threads.@spawn begin - st = lookup(convert(Ptr{Cvoid}, ip)) - # To correct line numbers for moving code, put it in the form expected by - # Base.update_stackframes_callback[] - stn = map(x->(x, 1), st) - try Base.invokelatest(Base.update_stackframes_callback[], stn) catch end - dict[UInt64(ip)] = map(first, stn) - end + for ip in data + # Lookup is expensive, so do it only once per ip. + haskey(dict, UInt64(ip)) && continue + st = lookup(convert(Ptr{Cvoid}, ip)) + # To correct line numbers for moving code, put it in the form expected by + # Base.update_stackframes_callback[] + stn = map(x->(x, 1), st) + try Base.invokelatest(Base.update_stackframes_callback[], stn) catch end + dict[UInt64(ip)] = map(first, stn) end return dict end