Skip to content

Commit

Permalink
store time of each profile sample
Browse files Browse the repository at this point in the history
  • Loading branch information
IanButterworth committed Aug 8, 2021
1 parent 96c7cb3 commit 7131a46
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
3 changes: 3 additions & 0 deletions src/signals-mach.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
3 changes: 3 additions & 0 deletions src/signals-unix.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
3 changes: 3 additions & 0 deletions src/signals-win.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
9 changes: 5 additions & 4 deletions stdlib/Profile/src/Profile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -735,12 +735,13 @@ function tree!(root::StackFrameTree{T}, all::Vector{UInt64}, lidict::Union{LineI
startframe = length(all)
skip = false
for i in startframe:-1:1
startframe - 1 <= i <= startframe - 2 && continue # skip metadata (its read ahead below)
startframe - 1 <= i <= startframe - 3 && continue # skip metadata (its read ahead below)
ip = all[i]
if ip == 0
# read metadata
taskid = all[i - 1]
threadid = all[i - 2]
# time = all[i - 1]
taskid = all[i - 2]
threadid = all[i - 3]
if !in(threadid, threads) || !in(taskid, tasks)
skip = true
continue
Expand Down

0 comments on commit 7131a46

Please sign in to comment.