Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
Comment on lines +23 to +24

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's nit-picking, but I would appreciate if you either stored the task as a void*, or even a size_t, and/or added a comment here indicating that this pointer is not rooted, and therefore might not even be live anymore, and you should never try to load it.

Can you send a tiny follow up to address this? :) Thanks!

I also like matching the julia and C structs as much as possible, so void* in both or size_t in both makes sense to me.

};

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

Expand Down
2 changes: 1 addition & 1 deletion src/julia_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ int jl_running_under_rr(int recheck) JL_NOTSAFEPOINT;
JL_DLLEXPORT uint64_t jl_hrtime(void) JL_NOTSAFEPOINT;

// number of cycles since power-on
static inline uint64_t cycleclock(void)
static inline uint64_t cycleclock(void) JL_NOTSAFEPOINT
{
#if defined(_CPU_X86_64_)
uint64_t low, high;
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 @@ -147,6 +149,8 @@ struct Alloc
type::Any
stacktrace::StackTrace
size::Int
task::Ptr{Cvoid}
timestamp::UInt64
end

struct AllocResults
Expand Down Expand Up @@ -180,7 +184,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