@@ -980,13 +980,14 @@ mutable struct StackFrameTree{T} # where T <: Union{UInt64, StackFrame}
980
980
flat_count:: Int # number of times this frame was in the flattened representation (unlike count, this'll sum to 100% of parent)
981
981
max_recur:: Int # maximum number of times this frame was the *top* of the recursion in the stack
982
982
count_recur:: Int # sum of the number of times this frame was the *top* of the recursion in a stack (divide by count to get an average)
983
+ sleeping:: Bool # whether this frame was in a sleeping state
983
984
down:: Dict{T, StackFrameTree{T}}
984
985
# construction workers:
985
986
recur:: Int
986
987
builder_key:: Vector{UInt64}
987
988
builder_value:: Vector{StackFrameTree{T}}
988
989
up:: StackFrameTree{T}
989
- StackFrameTree {T} () where {T} = new (UNKNOWN, 0 , 0 , 0 , 0 , 0 , Dict {T, StackFrameTree{T}} (), 0 , UInt64[], StackFrameTree{T}[])
990
+ StackFrameTree {T} () where {T} = new (UNKNOWN, 0 , 0 , 0 , 0 , 0 , true , Dict {T, StackFrameTree{T}} (), 0 , UInt64[], StackFrameTree{T}[])
990
991
end
991
992
992
993
@@ -1027,6 +1028,10 @@ function tree_format(frames::Vector{<:StackFrameTree}, level::Int, cols::Int, ma
1027
1028
base = string (base, " +" , nextra, " " )
1028
1029
end
1029
1030
strcount = rpad (string (frame. count), ndigcounts, " " )
1031
+ if frame. sleeping
1032
+ stroverhead = styled " {gray:$(stroverhead)}"
1033
+ strcount = styled " {gray:$(strcount)}"
1034
+ end
1030
1035
if li != UNKNOWN
1031
1036
if li. line == li. pointer
1032
1037
strs[i] = string (stroverhead, " ╎" , base, strcount, " " ,
@@ -1039,6 +1044,7 @@ function tree_format(frames::Vector{<:StackFrameTree}, level::Int, cols::Int, ma
1039
1044
else
1040
1045
fname = string (li. func)
1041
1046
end
1047
+ frame. sleeping && (fname = styled " {gray:$(fname)}" )
1042
1048
path, pkgname, filename = short_path (li. file, filenamemap)
1043
1049
if showpointer
1044
1050
fname = string (
@@ -1082,15 +1088,15 @@ function tree!(root::StackFrameTree{T}, all::Vector{UInt64}, lidict::Union{LineI
1082
1088
skip = false
1083
1089
nsleeping = 0
1084
1090
is_task_profile = false
1091
+ is_sleeping = true
1085
1092
for i in startframe: - 1 : 1
1086
1093
(startframe - 1 ) >= i >= (startframe - (nmeta + 1 )) && continue # skip metadata (it's read ahead below) and extra block end NULL IP
1087
1094
ip = all[i]
1088
1095
if is_block_end (all, i)
1089
1096
# read metadata
1090
1097
thread_sleeping_state = all[i - META_OFFSET_SLEEPSTATE] - 1 # subtract 1 as state is incremented to avoid being equal to 0
1091
- if thread_sleeping_state == 2
1092
- is_task_profile = true
1093
- end
1098
+ is_sleeping = thread_sleeping_state == 1
1099
+ is_task_profile = thread_sleeping_state == 2
1094
1100
# cpu_cycle_clock = all[i - META_OFFSET_CPUCYCLECLOCK]
1095
1101
taskid = all[i - META_OFFSET_TASKID]
1096
1102
threadid = all[i - META_OFFSET_THREADID]
@@ -1145,6 +1151,7 @@ function tree!(root::StackFrameTree{T}, all::Vector{UInt64}, lidict::Union{LineI
1145
1151
parent = build[j]
1146
1152
parent. recur += 1
1147
1153
parent. count_recur += 1
1154
+ parent. sleeping &= is_sleeping
1148
1155
found = true
1149
1156
break
1150
1157
end
@@ -1164,6 +1171,7 @@ function tree!(root::StackFrameTree{T}, all::Vector{UInt64}, lidict::Union{LineI
1164
1171
while this != = parent && (recur === :off || this. recur == 0 )
1165
1172
this. count += 1
1166
1173
this. recur = 1
1174
+ this. sleeping &= is_sleeping
1167
1175
this = this. up
1168
1176
end
1169
1177
end
@@ -1185,6 +1193,7 @@ function tree!(root::StackFrameTree{T}, all::Vector{UInt64}, lidict::Union{LineI
1185
1193
this. up = parent
1186
1194
this. count += 1
1187
1195
this. recur = 1
1196
+ this. sleeping &= is_sleeping
1188
1197
end
1189
1198
parent = this
1190
1199
end
0 commit comments