Skip to content

Commit 7131a46

Browse files
store time of each profile sample
1 parent 96c7cb3 commit 7131a46

File tree

4 files changed

+14
-4
lines changed

4 files changed

+14
-4
lines changed

src/signals-mach.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,9 @@ void *mach_profile_listener(void *arg)
596596
// store task id
597597
bt_data_prof[bt_size_cur++].uintptr = ptls->current_task;
598598

599+
// store time
600+
bt_data_prof[bt_size_cur++].uintptr = jl_hrtime();
601+
599602
// Mark the end of this block with 0
600603
bt_data_prof[bt_size_cur++].uintptr = 0;
601604
}

src/signals-unix.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -791,6 +791,9 @@ static void *signal_listener(void *arg)
791791
// store task id
792792
bt_data_prof[bt_size_cur++].uintptr = ptls->current_task;
793793

794+
// store time
795+
bt_data_prof[bt_size_cur++].uintptr = jl_hrtime();
796+
794797
// Mark the end of this block with 0
795798
bt_data_prof[bt_size_cur++].uintptr = 0;
796799
}

src/signals-win.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,9 @@ static DWORD WINAPI profile_bt( LPVOID lparam )
369369
// store task id
370370
bt_data_prof[bt_size_cur++].uintptr = ptls->current_task;
371371

372+
// store time
373+
bt_data_prof[bt_size_cur++].uintptr = jl_hrtime();
374+
372375
// Mark the end of this block with 0
373376
bt_data_prof[bt_size_cur++].uintptr = 0;
374377
}

stdlib/Profile/src/Profile.jl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ function fetch(;include_meta = false)
488488
return data
489489
else
490490
nblocks = count(iszero, data)
491-
nmeta = 2 # number of metadata fields (threadid, taskid)
491+
nmeta = 3 # number of metadata fields (threadid, taskid, time)
492492
data_stripped = Vector{UInt}(undef, length(data) - (nblocks * nmeta))
493493
j = length(data_stripped)
494494
i = length(data)
@@ -735,12 +735,13 @@ function tree!(root::StackFrameTree{T}, all::Vector{UInt64}, lidict::Union{LineI
735735
startframe = length(all)
736736
skip = false
737737
for i in startframe:-1:1
738-
startframe - 1 <= i <= startframe - 2 && continue # skip metadata (its read ahead below)
738+
startframe - 1 <= i <= startframe - 3 && continue # skip metadata (its read ahead below)
739739
ip = all[i]
740740
if ip == 0
741741
# read metadata
742-
taskid = all[i - 1]
743-
threadid = all[i - 2]
742+
# time = all[i - 1]
743+
taskid = all[i - 2]
744+
threadid = all[i - 3]
744745
if !in(threadid, threads) || !in(taskid, tasks)
745746
skip = true
746747
continue

0 commit comments

Comments
 (0)