Skip to content

Commit

Permalink
Merge pull request #48 from vilterp/pv-profile-allocs-type-name-cache
Browse files Browse the repository at this point in the history
alloc prof: memoize stringifying type name
  • Loading branch information
vchuravy authored Jan 23, 2022
2 parents df43527 + 5b54ef3 commit be54421
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/Allocs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,17 @@ function pprof(alloc_profile::Profile.Allocs.AllocResults = Profile.Allocs.fetch
end
end

type_name_cache = Dict{Any,String}()

function get_type_name(type::Any)
return get!(type_name_cache, type) do
return "Alloc: $(type)"
end
end

function construct_location_for_type(typename)
# TODO: Lol something less hacky than this:
return maybe_add_location(StackFrame("Alloc: $(typename)", "nothing", 0))
return maybe_add_location(StackFrame(get_type_name(typename), "nothing", 0))
end

for sample in alloc_profile.allocs # convert the sample.stack to vector of location_ids
Expand Down

0 comments on commit be54421

Please sign in to comment.