Skip to content

Commit ba394b1

Browse files
add the threadpool to thread labels (#246)
1 parent abf2151 commit ba394b1

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/ProfileView.jl

+12-3
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,14 @@ const window_wrefs = WeakKeyDict{Gtk4.GtkWindowLeaf,Nothing}()
143143
const tabname_allthreads = Symbol("All Threads")
144144
const tabname_alltasks = Symbol("All Tasks")
145145

146+
function get_thread_label(threadid::Int)
147+
@static if isdefined(Threads, :threadpooldescription)
148+
return Symbol(string(threadid , " (", Threads.threadpooldescription(threadid), ")"))
149+
else
150+
return Symbol(string(threadid , " (", Threads.threadpool(threadid), ")"))
151+
end
152+
end
153+
146154
NestedGraphDict = Dict{Symbol,Dict{Symbol,Node{NodeData}}}
147155
"""
148156
ProfileView.view([fcolor], data=Profile.fetch(); lidict=nothing, C=false, recur=:off, fontsize=14, windowname="Profile", kwargs...)
@@ -184,7 +192,8 @@ function view(fcolor, data::Vector{UInt64}; lidict=nothing, C=false, combine=tru
184192
end
185193
end
186194
end
187-
gdict[Symbol(threadid)] = gdict_inner
195+
thread_label = get_thread_label(threadid)
196+
gdict[thread_label] = gdict_inner
188197
end
189198
end
190199
return view(fcolor, gdict; data=data, lidict=lidict, kwargs...)
@@ -236,12 +245,12 @@ function viewgui(fcolor, gdict::NestedGraphDict; data=nothing, lidict=nothing, w
236245
nb_threads = GtkNotebook() # for holding the per-thread pages
237246
Gtk4.scrollable(nb_threads, true)
238247
Gtk4.show_tabs(nb_threads, length(thread_tabs) > 1)
239-
sort!(thread_tabs, by = s -> something(tryparse(Int, string(s)), 0)) # sorts thread_tabs as [all threads, 1, 2, 3 ....]
248+
sort!(thread_tabs, by = s -> s == tabname_allthreads ? "000" : string(s)) # sorts thread_tabs as [all threads, 1, 2, 3 ....]
240249

241250
for thread_tab in thread_tabs
242251
gdict_thread = gdict[thread_tab]
243252
task_tabs = collect(keys(gdict_thread))
244-
sort!(task_tabs, by = s -> s == tabname_alltasks ? "" : string(s)) # sorts thread_tabs as [all threads, 0xds ....]
253+
sort!(task_tabs, by = s -> s == tabname_alltasks ? "000" : string(s)) # sorts thread_tabs as [all threads, 0xds ....]
245254

246255
nb_tasks = GtkNotebook() # for holding the per-task pages
247256
Gtk4.scrollable(nb_tasks, true)

0 commit comments

Comments
 (0)