Stream: helpdesk (published)

Topic: ✔ Profiling Code that Hangs


view this post on Zulip Laura Demkowicz-Duffy (Jun 09 2023 at 15:01):

Hi all, I have quite a heavyweight function call which hangs fairly non-deterministically (the function is a Monte Carlo Tree Search). I've tried determining the problem with tools like Profile, but they seem to depend on the function terminating. I'm hesitant to pull out the debugger for this kind of code with a very deep call stack - is there a tool, julia or otherwise, which could help me find where it's spending all it's time?

view this post on Zulip Felix Kastner (Jun 09 2023 at 15:09):

Maybe this helps:

A fixed duration cpu profile can now be triggered by the user during running tasks without Profile being loaded first and the report will show during execution. On MacOS & FreeBSD press ctrl-t or raise a SIGINFO. For other platforms raise a SIGUSR1 i.e. % kill -USR1 $julia_pid. Not currently available on windows (#43179).

(from the v1.8 release notes)

view this post on Zulip Sukera (Jun 09 2023 at 15:09):

if you know that it's hanging, you can spam CTRL+C to force-throw an interrupt, which should print a stacktrace

view this post on Zulip Sukera (Jun 09 2023 at 15:10):

profiling-by-stacktrace works, because statistically speaking you're going to hit the hottest code most of the time

view this post on Zulip Michael Fiano (Jun 09 2023 at 15:12):

Interesting. Does Julia employ a statistical or deterministic cpu profiler?

view this post on Zulip Sukera (Jun 09 2023 at 15:14):

the builtin is statistical

view this post on Zulip Sukera (Jun 09 2023 at 15:15):

if you want CPU statistics, you'd need something like LIKWID.jl or MCAnalyzer.jl, if you want to go the simulation route

view this post on Zulip Michael Fiano (Jun 09 2023 at 15:16):

I was curious because the language I'm used to has both builtin. The latter (edit) is not very "modern" but is used to profile a selection of functions, with instrumentation, rather than taking samples of everything.

view this post on Zulip Laura Demkowicz-Duffy (Jun 09 2023 at 15:52):

Felix Kastner said:

Maybe this helps:

A fixed duration cpu profile can now be triggered by the user during running tasks without Profile being loaded first and the report will show during execution. On MacOS & FreeBSD press ctrl-t or raise a SIGINFO. For other platforms raise a SIGUSR1 i.e. % kill -USR1 $julia_pid. Not currently available on windows (#43179).

(from the v1.8 release notes)

That's a really cool feature, thanks for bringing that to my attention!

view this post on Zulip Notification Bot (Jun 09 2023 at 16:14):

Laura Demkowicz-Duffy has marked this topic as resolved.


Last updated: Dec 28 2024 at 04:38 UTC