-
Notifications
You must be signed in to change notification settings - Fork 9
Trigger a profile before terminating worker upon timeout #120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
a4bc5ee
525c176
f7f6d6d
e8e906f
2679113
3071046
2514451
fcb2b85
3407e7e
83ecc8c
6827599
864d6cf
ecd0d42
d1dc637
931bde4
699d37f
943ded4
c72cbea
52dbcce
1a29db0
d42ae31
43df1a8
9d4f1b9
9c72a0d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ module Workers | |
using Sockets, Serialization | ||
|
||
export Worker, remote_eval, remote_fetch, terminate!, WorkerTerminatedException | ||
export trigger_profile | ||
|
||
function try_with_timeout(f, timeout) | ||
cond = Threads.Condition() | ||
|
@@ -105,6 +106,25 @@ function watch_and_terminate!(w::Worker, ev::Threads.Event) | |
true | ||
end | ||
|
||
# Send signal to the given `Worker` process to trigger a profile. | ||
# Users can customise this profiling in the usual way, e.g. via | ||
# `JULIA_PROFILE_PEEK_HEAP_SNAPSHOT`, but `Profile.set_peek_duration`, `Profile.peek_report[]` | ||
# would have to be modified in the worker process. | ||
# See https://docs.julialang.org/en/v1/stdlib/Profile/#Triggered-During-Execution | ||
# Called when timeout_profile_wait is non-zero. | ||
function trigger_profile(w::Worker, timeout_profile_wait, from::Symbol=:manual) | ||
if !Sys.iswindows() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why not windows? because there isn't a SIGINFO equivalent? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good question! Looks like i did this because upstream Julia doesn't support this functionality on Windows... but idk why not |
||
@debug "sending profile request to worker $(w.pid) from $from" | ||
if Sys.islinux() | ||
kill(w.process, 10) # SIGUSR1 | ||
elseif Sys.isbsd() | ||
kill(w.process, 29) # SIGINFO | ||
end | ||
sleep(timeout_profile_wait) # Leave time for it to print the profile. | ||
end | ||
return nothing | ||
end | ||
|
||
# gracefully terminate a worker by sending a shutdown message | ||
# and waiting for the other tasks to perform worker shutdown | ||
function Base.close(w::Worker) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will throw an
InexactError
if you passInf
. Maybe that's fine?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah
Inf
s,NaN
s and negative values will throw at some point, but I don't think this is an issue in practice.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added a check for the negative numbers as we do the same thing for
timeout