Skip to content

Demo of Go runtime "virtual frame" support - #659

Draft
adonovan wants to merge 1 commit into
masterfrom
pprof-virtual-frame
Draft

adonovan wants to merge 1 commit into
masterfrom
pprof-virtual-frame

Conversation

@adonovan

Copy link
Copy Markdown
Collaborator

This commit is a sketch of the changes in the interpreter to integrate Starlark into all of the Go runtime's machinery for profiling CPU, allocation, etc.

In short, it consists of:

  • a declaration to the compiler that the local var 'fr' in Function.CallInternal is special, and should be made accessible to the unwinder.
  • an init-time declaration to the runtime that Function.CallInternal is the interpreter's "eval" function, for which a virtual frame should be emitted, plus:
    • a pair of expressions, derived from the value of fr, that yield the static "code" and dynamic "pc" of the current interpreter state. These expressions, which are safe to execute in an async signal handler, are denoted using the pprof's Op AST builder API.
    • a function called by the pprof encoder that converts the static "code" and dynamic "pc" values into a (symbol, file, line) triple that will appear in the profile.

The commit includes a profile.sh script that demonstrates the mixed Go/Starlark profiles produced by the interpreter.

This code depends on the proposed
compiler changes in https://go.dev/cl/831624 and
new runtime APIs sketched in https://go.dev/cl/831625.

DO NOT SUBMIT

This commit is a sketch of the changes in the interpreter
to integrate Starlark into all of the Go runtime's machinery
for profiling CPU, allocation, etc.

In short, it consists of:
- a declaration to the compiler that the local var 'fr' in
  Function.CallInternal is special, and should be made
  accessible to the unwinder.
- an init-time declaration to the runtime that
  Function.CallInternal is the interpreter's "eval"
  function, for which a virtual frame should be emitted,
  plus:
  - a pair of expressions, derived from the value of fr,
    that yield the static "code" and dynamic "pc" of the
    current interpreter state. These expressions, which
    are safe to execute in an async signal handler, are
    denoted using the pprof's Op AST builder API.
  - a function called by the pprof encoder that converts the
    static "code" and dynamic "pc" values into a
    (symbol, file, line) triple that will appear in the
    profile.

The commit includes a profile.sh script that demonstrates
the mixed Go/Starlark profiles produced by the interpreter.

This code depends on the proposed
compiler changes in https://go.dev/cl/831624 and
new runtime APIs sketched in https://go.dev/cl/831625.

DO NOT SUBMIT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant