-
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 3 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,23 @@ 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`, `Profile.set_peek_duration`, `Profile.peek_report[]` | ||
| # See https://docs.julialang.org/en/v1/stdlib/Profile/#Triggered-During-Execution | ||
| function trigger_profile(w::Worker, from::Symbol=:manual) | ||
| if !Sys.iswindows() | ||
|
Collaborator
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?
Member
Author
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 | ||
| end | ||
| sleep(120) # Leave time for it to print the profile. | ||
| 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.
it would probably be nice to make it configurable whether or not the trigger_profile is run, and with that the amount of time to wait (currently you have it at 120) to do the profile printing.