Skip to content

Commit 20adec5

Browse files
committed
Revert "Profile: multithread getdict! (redo of JuliaLang#43805) (JuliaLang#43816)"
This reverts commit e6fa3ec.
1 parent 9bf9a31 commit 20adec5

File tree

1 file changed

+9
-24
lines changed

1 file changed

+9
-24
lines changed

stdlib/Profile/src/Profile.jl

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -349,34 +349,19 @@ function getdict(data::Vector{UInt})
349349
end
350350

351351
function getdict!(dict::LineInfoDict, data::Vector{UInt})
352-
# we don't want metadata here as we're just looking up ips
353-
unique_ips = unique(has_meta(data) ? strip_meta(data) : data)
354-
n_unique_ips = length(unique_ips)
355-
n_unique_ips == 0 && return dict
356-
iplookups = similar(unique_ips, Vector{StackFrame})
357-
@sync for indexes_part in Iterators.partition(eachindex(unique_ips), div(n_unique_ips, Threads.nthreads(), RoundUp))
358-
Threads.@spawn begin
359-
for i in indexes_part
360-
iplookups[i] = _lookup_corrected(unique_ips[i])
361-
end
362-
end
363-
end
364-
for i in eachindex(unique_ips)
365-
dict[unique_ips[i]] = iplookups[i]
352+
for ip in data
353+
# Lookup is expensive, so do it only once per ip.
354+
haskey(dict, UInt64(ip)) && continue
355+
st = lookup(convert(Ptr{Cvoid}, ip))
356+
# To correct line numbers for moving code, put it in the form expected by
357+
# Base.update_stackframes_callback[]
358+
stn = map(x->(x, 1), st)
359+
try Base.invokelatest(Base.update_stackframes_callback[], stn) catch end
360+
dict[UInt64(ip)] = map(first, stn)
366361
end
367362
return dict
368363
end
369364

370-
function _lookup_corrected(ip::UInt)
371-
st = lookup(convert(Ptr{Cvoid}, ip))
372-
# To correct line numbers for moving code, put it in the form expected by
373-
# Base.update_stackframes_callback[]
374-
stn = map(x->(x, 1), st)
375-
# Note: Base.update_stackframes_callback[] should be data-race free
376-
try Base.invokelatest(Base.update_stackframes_callback[], stn) catch end
377-
return map(first, stn)
378-
end
379-
380365
"""
381366
flatten(btdata::Vector, lidict::LineInfoDict) -> (newdata::Vector{UInt64}, newdict::LineInfoFlatDict)
382367

0 commit comments

Comments
 (0)