Skip to content

Commit 3cfe5ca

Browse files
authored
Merge pull request #44162 from jpsamaroo/jps/alloc-ns-ct
Profile.Allocs: Add task and timestamp (take 2)
2 parents 1e86463 + 6463613 commit 3cfe5ca

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

src/gc-alloc-profiler.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ struct jl_raw_alloc_t {
2020
jl_datatype_t *type_address;
2121
jl_raw_backtrace_t backtrace;
2222
size_t size;
23+
jl_task_t *task;
24+
uint64_t timestamp;
2325
};
2426

2527
// == 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
132134
profile.allocs.emplace_back(jl_raw_alloc_t{
133135
type,
134136
get_raw_backtrace(),
135-
size
137+
size,
138+
jl_current_task,
139+
cycleclock()
136140
});
137141
}
138142

src/julia_internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ int jl_running_under_rr(int recheck) JL_NOTSAFEPOINT;
129129
JL_DLLEXPORT uint64_t jl_hrtime(void) JL_NOTSAFEPOINT;
130130

131131
// number of cycles since power-on
132-
static inline uint64_t cycleclock(void)
132+
static inline uint64_t cycleclock(void) JL_NOTSAFEPOINT
133133
{
134134
#if defined(_CPU_X86_64_)
135135
uint64_t low, high;

stdlib/Profile/src/Allocs.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ struct RawAlloc
1919
type::Ptr{Type}
2020
backtrace::RawBacktrace
2121
size::Csize_t
22+
task::Ptr{Cvoid}
23+
timestamp::UInt64
2224
end
2325

2426
# matches jl_profile_allocs_raw_results_t on the C side
@@ -121,6 +123,8 @@ struct Alloc
121123
type::Any
122124
stacktrace::StackTrace
123125
size::Int
126+
task::Ptr{Cvoid}
127+
timestamp::UInt64
124128
end
125129

126130
struct AllocResults
@@ -158,7 +162,9 @@ function decode_alloc(cache::BacktraceCache, raw_alloc::RawAlloc)::Alloc
158162
Alloc(
159163
load_type(raw_alloc.type),
160164
stacktrace_memoized(cache, load_backtrace(raw_alloc.backtrace)),
161-
UInt(raw_alloc.size)
165+
UInt(raw_alloc.size),
166+
raw_alloc.task,
167+
raw_alloc.timestamp
162168
)
163169
end
164170

0 commit comments

Comments
 (0)