Skip to content

[Lilit summer student development] Flamegraph integration - #192

Closed
oshadura wants to merge 18 commits into
root-project:masterfrom
oshadura:lilit-flamegraph
Closed

[Lilit summer student development] Flamegraph integration#192
oshadura wants to merge 18 commits into
root-project:masterfrom
oshadura:lilit-flamegraph

Conversation

@oshadura

Copy link
Copy Markdown
Contributor

@eguiraud I tried but I am confused why it works from the terminal but doesn't generate anything in ctest...

From rootbench build directory:

 export PATH=$PWD/FlameGraph-prefix/src/FlameGraph/:$PATH
./tools/flamegraph.sh -d . -b root/tmva/tmva/ConvNetCpuBenchmarks -c -m 
.......
----------------------------------------------------------------------
Benchmark                            Time             CPU   Iterations
----------------------------------------------------------------------
BM_ConvolutionalNetwork_CPU 39306567750 ns   38953830955 ns            1
[ perf record: Woken up 12 times to write data ]
[ perf record: Captured and wrote 3,832 MB perf.data (381 samples) ]

and both pngs (memory and CPU flamegraphs) are beautifully generated!

But from ctest:

ctest -R rootbench-fixture-flamegraphcpu-ConvNetCpuBenchmarks
......
69: [ perf record: Woken up 4 times to write data ]
69: [ perf record: Captured and wrote 0,000 MB (null) ]
69: failed to open perf.data: No such file or directory  (try 'perf record' first)
69: ERROR: No stack counts found
1/1 Test #69: rootbench-fixture-flamegraph-ConvNetCpuBenchmarks ...***Failed  119.84 sec

0% tests passed, 1 tests failed out of 1

Total Test time (real) = 119.89 sec

The following tests FAILED:
	 69 - rootbench-fixture-flamegraph-ConvNetCpuBenchmarks (Failed)
Errors while running CTest

The command is the same for both and I see the benchmark is running actually...

@oshadura

Copy link
Copy Markdown
Contributor Author

Rebased and readapted from #94

@eguiraud

Copy link
Copy Markdown
Contributor

@oshadura I bet it's a "current working directory" issue. You can check the verbose ctest -V -R rootbench-fixture-flamegraphcpu-ConvNetCpuBenchmarks and also check, after the test failed, in which directory the perf.data file has been created.

@vgvassilev

Copy link
Copy Markdown
Member

Looks like the behavior of perf record is different if being called from ctest. Let's aim for merging the script and then the rest.

@guitargeek

Copy link
Copy Markdown
Contributor

Thank you @oshadura and Lilit for this work, and sorry it sat unresolved for so long!

Profiling the benchmarks is still something we very much want to encourage, but in the meantime the mechanics of this PR have been absorbed by perf itself: since Linux 5.8, perf script report flamegraph generates an interactive flame graph directly from a recording, with no external scripts needed. That covers what tools/flamegraph.sh automated, so instead of merging the integration we added a short "Profiling a benchmark" recipe to the README in #309:

The per-benchmark automation via ctest fixtures (the part that was still fighting the empty-perf.data mystery here) would only pay off with infrastructure that publishes the generated graphs, which we currently don't have. If that comes back, this PR remains a useful reference for how to wire it up.

Closing in favor of the documentation approach. Thanks again for exploring this!

@guitargeek guitargeek closed this Sep 4, 2026
guitargeek added a commit that referenced this pull request Sep 4, 2026
Modern perf can generate flame graphs natively, so a short recipe in
the README replaces the flame graph integration that was proposed in
PR #192.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants