diff --git a/src/signals-mach.c b/src/signals-mach.c index 8ec6e8d7bb1df..848e602ade188 100644 --- a/src/signals-mach.c +++ b/src/signals-mach.c @@ -596,6 +596,9 @@ void *mach_profile_listener(void *arg) // store task id bt_data_prof[bt_size_cur++].uintptr = ptls->current_task; + // store time + bt_data_prof[bt_size_cur++].uintptr = jl_hrtime(); + // Mark the end of this block with 0 bt_data_prof[bt_size_cur++].uintptr = 0; } diff --git a/src/signals-unix.c b/src/signals-unix.c index 0da4658b3c189..3385ed32ba875 100644 --- a/src/signals-unix.c +++ b/src/signals-unix.c @@ -791,6 +791,9 @@ static void *signal_listener(void *arg) // store task id bt_data_prof[bt_size_cur++].uintptr = ptls->current_task; + // store time + bt_data_prof[bt_size_cur++].uintptr = jl_hrtime(); + // Mark the end of this block with 0 bt_data_prof[bt_size_cur++].uintptr = 0; } diff --git a/src/signals-win.c b/src/signals-win.c index f5fe989ba41e0..b31bfe8f5d72a 100644 --- a/src/signals-win.c +++ b/src/signals-win.c @@ -369,6 +369,9 @@ static DWORD WINAPI profile_bt( LPVOID lparam ) // store task id bt_data_prof[bt_size_cur++].uintptr = ptls->current_task; + // store time + bt_data_prof[bt_size_cur++].uintptr = jl_hrtime(); + // Mark the end of this block with 0 bt_data_prof[bt_size_cur++].uintptr = 0; } diff --git a/stdlib/Profile/src/Profile.jl b/stdlib/Profile/src/Profile.jl index 014120fb67a84..a6d88c440b6b1 100644 --- a/stdlib/Profile/src/Profile.jl +++ b/stdlib/Profile/src/Profile.jl @@ -488,7 +488,7 @@ function fetch(;include_meta = false) return data else nblocks = count(iszero, data) - nmeta = 2 # number of metadata fields (threadid, taskid) + nmeta = 3 # number of metadata fields (threadid, taskid, time) data_stripped = Vector{UInt}(undef, length(data) - (nblocks * nmeta)) j = length(data_stripped) i = length(data) @@ -736,13 +736,14 @@ function tree!(root::StackFrameTree{T}, all::Vector{UInt64}, lidict::Union{LineI skip = false for i in startframe:-1:1 ip = all[i] - if i == startframe - 1 # task metadata position + i == startframe - 1 && continue # time metadata position + if i == startframe - 2 # task metadata position if !in(ip, tasks) skip = true end continue end - if i == startframe - 2 # thread metadata position + if i == startframe - 3 # thread metadata position if !in(ip, threads) skip = true end