Skip to content

Commit

Permalink
Profile.Allocs: Add task and timestamp (#44055)
Browse files Browse the repository at this point in the history
  • Loading branch information
jpsamaroo authored Feb 12, 2022
1 parent 071ae18 commit bfc9431
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/gc-alloc-profiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ struct jl_raw_alloc_t {
jl_datatype_t *type_address;
jl_raw_backtrace_t backtrace;
size_t size;
jl_task_t *task;
uint64_t timestamp;
};

// == These structs define the global singleton profile buffer that will be used by
Expand Down Expand Up @@ -132,7 +134,9 @@ void _maybe_record_alloc_to_profile(jl_value_t *val, size_t size, jl_datatype_t
profile.allocs.emplace_back(jl_raw_alloc_t{
type,
get_raw_backtrace(),
size
size,
jl_current_task,
cycleclock()
});
}

Expand Down
8 changes: 7 additions & 1 deletion stdlib/Profile/src/Allocs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ struct RawAlloc
type::Ptr{Type}
backtrace::RawBacktrace
size::Csize_t
task::Ptr{Cvoid}
timestamp::UInt64
end

# matches jl_profile_allocs_raw_results_t on the C side
Expand Down Expand Up @@ -121,6 +123,8 @@ struct Alloc
type::Any
stacktrace::StackTrace
size::Int
task::Ptr{Cvoid}
timestamp::UInt64
end

struct AllocResults
Expand Down Expand Up @@ -158,7 +162,9 @@ function decode_alloc(cache::BacktraceCache, raw_alloc::RawAlloc)::Alloc
Alloc(
load_type(raw_alloc.type),
stacktrace_memoized(cache, load_backtrace(raw_alloc.backtrace)),
UInt(raw_alloc.size)
UInt(raw_alloc.size),
raw_alloc.task,
raw_alloc.timestamp
)
end

Expand Down

0 comments on commit bfc9431

Please sign in to comment.