Skip to content

Commit a71c1f0

Browse files
committed
Improve debugging utilities
1 parent d7d1b0a commit a71c1f0

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

src/sch/Sch.jl

+3-3
Original file line numberDiff line numberDiff line change
@@ -868,12 +868,12 @@ function do_task(to_proc, extra_util, thunk_id, f, data, send_result, persist, c
868868
if ((extra_util isa MaxUtilization) && (real_util[] > 0)) ||
869869
((extra_util isa Real) && (extra_util + real_util[] > cap))
870870
# Fully subscribed, wait and re-check
871-
@debug "($(myid())) $f Waiting for free $(typeof(to_proc)): $extra_util | $(real_util[])/$cap"
871+
@debug "($(myid())) $f ($thunk_id) Waiting for free $(typeof(to_proc)): $extra_util | $(real_util[])/$cap"
872872
unlock(ACTIVE_TASKS_LOCK)
873873
wait(TASK_SYNC)
874874
else
875875
# Under-subscribed, calculate extra utilization and execute thunk
876-
@debug "($(myid())) Using available $to_proc: $extra_util | $(real_util[])/$cap"
876+
@debug "($(myid())) ($thunk_id) Using available $to_proc: $extra_util | $(real_util[])/$cap"
877877
extra_util = if extra_util isa MaxUtilization
878878
count(c->typeof(c)===typeof(to_proc), children(from_proc))
879879
else
@@ -911,7 +911,7 @@ function do_task(to_proc, extra_util, thunk_id, f, data, send_result, persist, c
911911
lock(ACTIVE_TASKS_LOCK) do
912912
real_util[] -= extra_util
913913
end
914-
@debug "($(myid())) Releasing $(typeof(to_proc)): $extra_util | $(real_util[])/$cap"
914+
@debug "($(myid())) ($thunk_id) Releasing $(typeof(to_proc)): $extra_util | $(real_util[])/$cap"
915915
notify(TASK_SYNC)
916916
metadata = (
917917
pressure=real_util[],

src/sch/util.jl

+16-6
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,13 @@ function set_failed!(state, origin, thunk=origin)
6161
end
6262

6363
"Internal utility, useful for debugging scheduler state."
64-
function print_sch_status(state, thunk)
64+
function print_sch_status(state, thunk; kwargs...)
6565
iob = IOBuffer()
66-
print_sch_status(iob, state, thunk)
66+
print_sch_status(iob, state, thunk; kwargs...)
6767
seek(iob, 0)
6868
write(stderr, iob)
6969
end
70-
function print_sch_status(io::IO, state, thunk; offset=0, limit=5)
70+
function print_sch_status(io::IO, state, thunk; offset=0, limit=5, max_inputs=3)
7171
function status_string(node)
7272
status = ""
7373
if node in state.errored
@@ -79,15 +79,25 @@ function print_sch_status(io::IO, state, thunk; offset=0, limit=5)
7979
status *= "R"
8080
elseif haskey(state.cache, node)
8181
status *= "C"
82+
elseif node in state.finished
83+
status *= "F"
8284
else
8385
status *= "?"
8486
end
8587
status
8688
end
87-
offset == 0 && print(io, "($(status_string(thunk))) ")
89+
if offset == 0
90+
println(io, "Ready ($(length(state.ready))): $(join(map(t->t.id, state.ready), ','))")
91+
println(io, "Running: ($(length(state.running))): $(join(map(t->t.id, collect(state.running)), ','))")
92+
print(io, "($(status_string(thunk))) ")
93+
end
8894
println(io, "$(thunk.id): $(thunk.f)")
89-
for input in thunk.inputs
95+
for (idx,input) in enumerate(thunk.inputs)
9096
input isa Thunk || continue
97+
if idx > max_inputs
98+
println(io, repeat(' ', offset+2), "")
99+
break
100+
end
91101
status = status_string(input)
92102
if haskey(state.waiting, thunk) && input in state.waiting[thunk]
93103
status *= "W"
@@ -99,7 +109,7 @@ function print_sch_status(io::IO, state, thunk; offset=0, limit=5)
99109
status *= "d"
100110
end
101111
if haskey(state.futures, input)
102-
status *= "f$(length(state.futures[input]))"
112+
status *= "f($(length(state.futures[input])))"
103113
end
104114
print(io, repeat(' ', offset+2), "($status) ")
105115
if limit > 0

0 commit comments

Comments
 (0)