Skip to content

Commit

Permalink
get sizes to work again
Browse files Browse the repository at this point in the history
  • Loading branch information
vilterp committed Dec 15, 2021
1 parent ba03edf commit 439f06b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
5 changes: 2 additions & 3 deletions src/gc-alloc-profiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ void push_raw_alloc(struct RawAllocProfile *profile, size_t type_tag, size_t byt
} else {
jl_array_ptr_1d_push(profile->alloc_types, (jl_value_t*)jl_nothing_type);
}
// jl_array_ptr_1d_push(profile->alloc_sizes, bytes_allocated);
// TODO: push this onto this array without boxing it
jl_array_ptr_1d_push(profile->alloc_sizes, jl_box_uint64(bytes_allocated));
jl_array_ptr_1d_push(profile->alloc_bts, (jl_value_t *)bt);
jl_array_ptr_1d_push(profile->alloc_bt2s, (jl_value_t *)bt2);
}
Expand Down Expand Up @@ -76,8 +77,6 @@ void _record_allocated_value(jl_value_t *val, size_t size) JL_NOTSAFEPOINT {

// profile->type_address_by_value_address[(size_t)val] = (size_t)type;

auto bytes_allocated = 5; // TODO: where were we getting this from?

g_alloc_profile_enabled = false;
push_raw_alloc(profile, type_tag, size);
g_alloc_profile_enabled = true;
Expand Down
14 changes: 10 additions & 4 deletions stdlib/AllocProfile/src/AllocProfile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const ExtendedEntryObj = Union{
# matches RawAllocResults on the C side
struct RawAllocProfile
alloc_types::Vector{Ptr{Type}}
alloc_sizes::Vector{Csize_t}
alloc_sizes::Vector{Ptr{Csize_t}}
alloc_bts::Vector{Vector{Ptr{Cvoid}}}
alloc_bt2s::Vector{Vector{ExtendedEntryObj}}

Expand Down Expand Up @@ -135,15 +135,21 @@ function decode(raw_results::RawAllocProfile)::AllocResults
cache = BacktraceCache()
allocs = Vector{Alloc}()

@assert length(raw_results.alloc_bts) == length(raw_results.alloc_bt2s) == length(raw_results.alloc_types)
@assert length(raw_results.alloc_bts) ==
length(raw_results.alloc_bt2s) ==
length(raw_results.alloc_types) ==
length(raw_results.alloc_sizes)

for i in 1:length(raw_results.alloc_bts)
bt = raw_results.alloc_bts[i]
bt2 = raw_results.alloc_bt2s[i]
type = load_type(raw_results.alloc_types[i])
type_tag = raw_results.alloc_types[i]
size = ccall(:jl_unbox_uint64, UInt64, (Ptr{Csize_t},), raw_results.alloc_sizes[i])

type = load_type(type_tag)
back_trace = _reformat_bt_custom(bt, bt2)
stack_trace = stacktrace_memoized(cache, back_trace)
size = 5 # TODO: grab this

push!(allocs, Alloc(
type,
stack_trace,
Expand Down

0 comments on commit 439f06b

Please sign in to comment.