Prototype: Rudimentary stack profiler #529
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We have a relatively large jsonnet code base (source), and I was trying to profile slow jsonnet invocations.
The golang-level profile via
JSONNET_CPU_PROFILE
wasn't very helpful in this regard. And tracing individual calls by addingstd.trace
was quite combersome.I prototyped a little sampling stack profiler. It is not very sophisticated. It samples stacks for 1% of calls to
EvalInCleanEnv
. Those stacks can then be visualised as a flamegraph.Usage:
There's plenty of room for improvement:
That said, the results I got from it so far look quite usable.
It's unlikely that I'll have much time to work on this and develop it into a fully-fledged solution.
I wanted to share what I have in case it's useful for others, or in case someone feels inspired to take the idea and develop it further.