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

profiling: include interpreter frames #43796

Open
vilterp opened this issue Jan 13, 2022 · 2 comments
Open

profiling: include interpreter frames #43796

vilterp opened this issue Jan 13, 2022 · 2 comments
Labels
feature Indicates new feature / enhancement requests profiler

Comments

@vilterp
Copy link
Contributor

vilterp commented Jan 13, 2022

Background

There are two types of stack frames: instruction pointers (to either C code or generated Julia code) and interpreter frames (Julia code being interpreted at runtime).

Problem

Interpreter frames only show up as unknown in CPU and allocation profiles.

Underlying issue

The backtrace buffers used by the CPU and Alloc profilers aren't GC roots, so the objects they point to (interpreter frames) can get garbage collected before a profiler user deferences them while decoding the profile. If you're not careful, this segfaults the process.

The CPU and alloc profiler currently sidestep this problem by using the StackTraces.lookup function to decode stack frames from raw backtrace buffers, which falls back on returning this "unknown" frame when it sees an interpreter frame:

isempty(infos) && return [StackFrame(empty_sym, empty_sym, -1, nothing, true, false, pointer)] # this is equal to UNKNOWN

These don't seem to occur to frequently in practice, so we've gotten by without truly solving this problem.

Possible fix

In another memory profiling PR (#33467), @maleadt solved this problem by modifying the garbage collector's mark phase to find these pointers in backtrace buffers, thereby preventing them from being collected. Perhaps that change can be merged separately, so then both the allocation and CPU profilers can use reformat_bt, and include interpreter frames.

@vilterp vilterp mentioned this issue Jan 13, 2022
7 tasks
@NHDaly
Copy link
Member

NHDaly commented Jan 13, 2022

For more information, I think these interpreter frames currently show up as unknown in the profiles collected via the Profile package. This issue is about teaching the Profiler to understand the interpreter frames in the stack traces it samples, so that it can report the frames being interpreted, instead of unknown. 👍

@vilterp
Copy link
Contributor Author

vilterp commented Jan 13, 2022

Thanks; edited a bit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Indicates new feature / enhancement requests profiler
Projects
None yet
Development

No branches or pull requests

3 participants