Skip to content

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