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

Rudimentary stack profiler #1

Merged

Conversation

B13rg
Copy link

@B13rg B13rg commented Apr 6, 2025

Usage:

JSONNET_STACK_PROFILE=stacks.out jsonnet main.jsonnet
cat stacks.out | flamegraph.pl --hash > flamegraph.svg

google#529

Todo:

There's plenty of room for improvement:

Making the code nicer
Including a time component (since we currently assume each eval takes a fixed amount of time)
Buffering stacks in memory with their counts and writing out aggregated counts in the end

This is very interesting. I was thinking about doing something like that myself, but didn't have much time recently.
I'd like to refactor it slightly (eliminate globals, extract all profiling logic to a separate function, so that in the normal flow it's just one check and one function call). Otherwise it looks good.

Usage:

  JSONNET_STACK_PROFILE=stacks.out jsonnet main.jsonnet
  cat stacks.out | flamegraph.pl --hash > flamegraph.svg
@B13rg B13rg merged commit ec39940 into ice-bergtech:stack_profiler Apr 6, 2025
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.

2 participants