From bfc94311badd3be87b49ef446473a058235fa19a Mon Sep 17 00:00:00 2001 From: Julian Samaroo Date: Sat, 12 Feb 2022 15:35:13 -0600 Subject: [PATCH] Profile.Allocs: Add task and timestamp (#44055) --- src/gc-alloc-profiler.cpp | 6 +++++- stdlib/Profile/src/Allocs.jl | 8 +++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/gc-alloc-profiler.cpp b/src/gc-alloc-profiler.cpp index c799e10143478..a5af9031cd0e3 100644 --- a/src/gc-alloc-profiler.cpp +++ b/src/gc-alloc-profiler.cpp @@ -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 @@ -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() }); } diff --git a/stdlib/Profile/src/Allocs.jl b/stdlib/Profile/src/Allocs.jl index 15a7afbff76fe..aa689936d4598 100644 --- a/stdlib/Profile/src/Allocs.jl +++ b/stdlib/Profile/src/Allocs.jl @@ -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 @@ -121,6 +123,8 @@ struct Alloc type::Any stacktrace::StackTrace size::Int + task::Ptr{Cvoid} + timestamp::UInt64 end struct AllocResults @@ -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