Skip to content

Conversation

@kaimast
Copy link
Collaborator

@kaimast kaimast commented Aug 22, 2025

Motivation

Generating flamegraphs using stack-based profilers, such as perftools or cargo flamegraph is great to measure CPU-bound synchronous workloads. For asynchronous or I/O bound-code tracing allows emitting information ("spans") about when a certain async function was started and finished, even if that function started/stopped multiple times, was waiting for a system call, or moved between threads.

The tracing spans can then be passed to different backends. I am particular interested in flamegraph/flamechart generation for my use case, but it also works with, for example, real-time profilers, such as tracy.

Proposed Changes

This PR adds tracing::instrument to various performance-critical functions when the instrumentation feature is enabled.

This allows, for example, generating flame graphs as is done in snarkOS PR #3916

@kaimast kaimast force-pushed the feat/tracing-instrument branch 3 times, most recently from f9ee562 to 8de48b0 Compare August 29, 2025 03:35
@kaimast kaimast force-pushed the feat/tracing-instrument branch from 8de48b0 to d0ce260 Compare September 6, 2025 15:22
@kaimast kaimast force-pushed the feat/tracing-instrument branch from d0ce260 to 0d0b94b Compare September 24, 2025 21:05
@kaimast kaimast force-pushed the feat/tracing-instrument branch from 0d0b94b to a42fe8c Compare October 7, 2025 01:37
@kaimast kaimast marked this pull request as ready for review October 7, 2025 01:39
@kaimast kaimast changed the title [WIP] Add tracing::instrument to allow generating flamegraphs [Feature] Add tracing::instrument to allow generating flame graphs Oct 7, 2025
@kaimast kaimast requested a review from ljedrz October 7, 2025 04:24
Copy link
Collaborator

@ljedrz ljedrz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM in general, left some nits and suggestions

@vicsn vicsn self-requested a review October 7, 2025 09:11
@kaimast
Copy link
Collaborator Author

kaimast commented Oct 31, 2025

@vicsn I added a short motivation to the PR description.

@vicsn
Copy link
Collaborator

vicsn commented Nov 2, 2025

@vicsn I added a short motivation to the PR description.

Thank you, that seems valuable. Would this approach be able to replace ProvableHQ/snarkOS#3930 and create a similar graph? Or will we get a different representation? I'm happy to delay merging snarkOS PR 3930 until we hone in on the specific method we want to support long-term

@kaimast
Copy link
Collaborator Author

kaimast commented Nov 7, 2025

I think there are ways to generate similar graphs with tracing. However, I should be fine to keep both for now, and we can revise it later.

@kaimast kaimast force-pushed the feat/tracing-instrument branch from 68bc54d to 0ba29ef Compare December 1, 2025 18:44
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.

4 participants