Skip to content

Commit

Permalink
Profile: Fix stdlib paths (#55327)
Browse files Browse the repository at this point in the history
(cherry picked from commit b759fe2)
  • Loading branch information
IanButterworth authored and KristofferC committed Aug 2, 2024
1 parent 2b31eab commit 78ed775
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
8 changes: 4 additions & 4 deletions src/signals-mach.c
Original file line number Diff line number Diff line change
Expand Up @@ -717,16 +717,16 @@ void *mach_profile_listener(void *arg)
#endif
jl_ptls_t ptls = jl_atomic_load_relaxed(&jl_all_tls_states)[i];

// store threadid but add 1 as 0 is preserved to indicate end of block
// META_OFFSET_THREADID store threadid but add 1 as 0 is preserved to indicate end of block
bt_data_prof[bt_size_cur++].uintptr = ptls->tid + 1;

// store task id (never null)
// META_OFFSET_TASKID store task id (never null)
bt_data_prof[bt_size_cur++].jlvalue = (jl_value_t*)jl_atomic_load_relaxed(&ptls->current_task);

// store cpu cycle clock
// META_OFFSET_CPUCYCLECLOCK store cpu cycle clock
bt_data_prof[bt_size_cur++].uintptr = cycleclock();

// store whether thread is sleeping but add 1 as 0 is preserved to indicate end of block
// META_OFFSET_SLEEPSTATE store whether thread is sleeping but add 1 as 0 is preserved to indicate end of block
bt_data_prof[bt_size_cur++].uintptr = jl_atomic_load_relaxed(&ptls->sleep_check_state) + 1;

// Mark the end of this block with two 0's
Expand Down
8 changes: 4 additions & 4 deletions src/signals-unix.c
Original file line number Diff line number Diff line change
Expand Up @@ -914,16 +914,16 @@ static void *signal_listener(void *arg)

jl_ptls_t ptls2 = jl_atomic_load_relaxed(&jl_all_tls_states)[i];

// store threadid but add 1 as 0 is preserved to indicate end of block
// META_OFFSET_THREADID store threadid but add 1 as 0 is preserved to indicate end of block
bt_data_prof[bt_size_cur++].uintptr = ptls2->tid + 1;

// store task id (never null)
// META_OFFSET_TASKID store task id (never null)
bt_data_prof[bt_size_cur++].jlvalue = (jl_value_t*)jl_atomic_load_relaxed(&ptls2->current_task);

// store cpu cycle clock
// META_OFFSET_CPUCYCLECLOCK store cpu cycle clock
bt_data_prof[bt_size_cur++].uintptr = cycleclock();

// store whether thread is sleeping but add 1 as 0 is preserved to indicate end of block
// META_OFFSET_SLEEPSTATE store whether thread is sleeping but add 1 as 0 is preserved to indicate end of block
bt_data_prof[bt_size_cur++].uintptr = jl_atomic_load_relaxed(&ptls2->sleep_check_state) + 1;

// Mark the end of this block with two 0's
Expand Down
8 changes: 4 additions & 4 deletions src/signals-win.c
Original file line number Diff line number Diff line change
Expand Up @@ -420,16 +420,16 @@ static DWORD WINAPI profile_bt( LPVOID lparam )

jl_ptls_t ptls = jl_atomic_load_relaxed(&jl_all_tls_states)[0]; // given only profiling hMainThread

// store threadid but add 1 as 0 is preserved to indicate end of block
// META_OFFSET_THREADID store threadid but add 1 as 0 is preserved to indicate end of block
bt_data_prof[bt_size_cur++].uintptr = ptls->tid + 1;

// store task id (never null)
// META_OFFSET_TASKID store task id (never null)
bt_data_prof[bt_size_cur++].jlvalue = (jl_value_t*)jl_atomic_load_relaxed(&ptls->current_task);

// store cpu cycle clock
// META_OFFSET_CPUCYCLECLOCK store cpu cycle clock
bt_data_prof[bt_size_cur++].uintptr = cycleclock();

// store whether thread is sleeping but add 1 as 0 is preserved to indicate end of block
// META_OFFSET_SLEEPSTATE store whether thread is sleeping but add 1 as 0 is preserved to indicate end of block
bt_data_prof[bt_size_cur++].uintptr = jl_atomic_load_relaxed(&ptls->sleep_check_state) + 1;

// Mark the end of this block with two 0's
Expand Down
4 changes: 2 additions & 2 deletions stdlib/Profile/src/Profile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ end
# based on the package ecosystem
function short_path(spath::Symbol, filenamecache::Dict{Symbol, String})
return get!(filenamecache, spath) do
path = string(spath)
path = Base.fixup_stdlib_path(string(spath))
if isabspath(path)
if ispath(path)
# try to replace the file-system prefix with a short "@Module" one,
Expand Down Expand Up @@ -683,7 +683,7 @@ function add_fake_meta(data; threadid = 1, taskid = 0xf0f0f0f0)
for i = 1:length(data)
val = data[i]
if iszero(val)
# (threadid, taskid, cpu_cycle_clock, thread_sleeping)
# META_OFFSET_THREADID, META_OFFSET_TASKID, META_OFFSET_CPUCYCLECLOCK, META_OFFSET_SLEEPSTATE
push!(data_with_meta, threadid, taskid, cpu_clock_cycle+=1, false+1, 0, 0)
else
push!(data_with_meta, val)
Expand Down

0 comments on commit 78ed775

Please sign in to comment.