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 a4a83f7 commit ddf1cbf
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 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
7 changes: 4 additions & 3 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 @@ -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
Expand Down

0 comments on commit ddf1cbf

Please sign in to comment.