Skip to content
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

Profile: print profile peek to stderr #48291

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions stdlib/Profile/src/Profile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ function profile_printing_listener()
wait(PROFILE_PRINT_COND[])
peek_report[]()
if get(ENV, "JULIA_PROFILE_PEEK_HEAP_SNAPSHOT", nothing) === "1"
println("Saving heap snapshot...")
println(stderr, "Saving heap snapshot...")
fname = take_heap_snapshot()
println("Heap snapshot saved to `$(fname)`")
println(stderr, "Heap snapshot saved to `$(fname)`")
end
end
catch ex
Expand All @@ -54,9 +54,9 @@ end
# An internal function called to show the report after an information request (SIGINFO or SIGUSR1).
function _peek_report()
iob = IOBuffer()
ioc = IOContext(IOContext(iob, stdout), :displaysize=>displaysize(stdout))
ioc = IOContext(IOContext(iob, stderr), :displaysize=>displaysize(stderr))
print(ioc, groupby = [:thread, :task])
Base.print(stdout, String(take!(iob)))
Base.print(stderr, String(take!(iob)))
end
# This is a ref so that it can be overridden by other profile info consumers.
const peek_report = Ref{Function}(_peek_report)
Expand Down
4 changes: 2 additions & 2 deletions stdlib/Profile/test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -199,14 +199,14 @@ if Sys.isbsd() || Sys.islinux()
let cmd = Base.julia_cmd()
script = """
x = rand(1000, 1000)
println("started")
println(stderr, "started")
while true
x * x
yield()
end
"""
iob = Base.BufferStream()
p = run(pipeline(`$cmd -e $script`, stderr = devnull, stdout = iob), wait = false)
p = run(pipeline(`$cmd -e $script`, stderr = iob, stdout = devnull), wait = false)
t = Timer(120) do t
# should be under 10 seconds, so give it 2 minutes then report failure
println("KILLING BY PROFILE TEST WATCHDOG\n")
Expand Down