Skip to content

Commit

Permalink
Profile: print profile peek to stderr (#48291)
Browse files Browse the repository at this point in the history
  • Loading branch information
IanButterworth authored Jan 17, 2023
1 parent 388864a commit 36007b7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
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

0 comments on commit 36007b7

Please sign in to comment.