Skip to content

feat: support flamegraphs in Java walltime#2

Closed
not-matthias wants to merge 12 commits intocod-2308-walltime-benchmarks-without-flamegraphsfrom
cod-2309-walltime-benchmarks-with-flamegraphs
Closed

feat: support flamegraphs in Java walltime#2
not-matthias wants to merge 12 commits intocod-2308-walltime-benchmarks-without-flamegraphsfrom
cod-2309-walltime-benchmarks-with-flamegraphs

Conversation

@not-matthias
Copy link
Copy Markdown
Member

@not-matthias not-matthias commented Mar 9, 2026

No description provided.

@linear
Copy link
Copy Markdown

linear bot commented Mar 9, 2026

COD-2309 Walltime benchmarks WITH flamegraphs

What?

Builds on top of COD-2308, adds:

  • Runner: Pass JVM flags
  • Integration: Add root frame
  • Backend: Process flamegraph, resolve symbols

Other stuff that might be needed:

  • Node Origin
  • Debug symbols (file, line)

How?

  • Compare JFR (and other profilers) against perf

@not-matthias not-matthias changed the base branch from main to cod-2308-walltime-benchmarks-without-flamegraphs March 9, 2026 17:32
@avalanche-staging
Copy link
Copy Markdown

avalanche-staging bot commented Mar 9, 2026

Merging this PR will improve performance by ×270

⚠️ Unknown Walltime execution environment detected

Using the Walltime instrument on standard Hosted Runners will lead to inconsistent data.

For the most accurate results, we recommend using CodSpeed Macro Runners: bare-metal machines fine-tuned for performance measurement consistency.

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 3 improved benchmarks
✅ 6 untouched benchmarks

Performance Changes

Benchmark BASE HEAD Efficiency
bench.RleBenchmark.encode 274 µs 1 µs ×270
bench.RleBenchmark.decode 1,896.2 ns 737.4 ns ×2.6
bench.FibBenchmark.fib 9.5 ms 3.3 ms ×2.8

Comparing cod-2309-walltime-benchmarks-with-flamegraphs (a606260) with cod-2308-walltime-benchmarks-without-flamegraphs (580ee7c)

Open in CodSpeed

@not-matthias not-matthias force-pushed the cod-2309-walltime-benchmarks-with-flamegraphs branch 2 times, most recently from 9fb8b8d to 1cbf994 Compare March 9, 2026 17:56
@not-matthias not-matthias force-pushed the cod-2308-walltime-benchmarks-without-flamegraphs branch 4 times, most recently from 7baf522 to fd966b0 Compare March 10, 2026 15:02
@not-matthias not-matthias force-pushed the cod-2309-walltime-benchmarks-with-flamegraphs branch from a606260 to 0019809 Compare March 10, 2026 15:12
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Mar 10, 2026

Merging this PR will create unknown performance changes

🆕 125 new benchmarks
⏩ 9 skipped benchmarks1

Performance Changes

Benchmark BASE HEAD Efficiency
🆕 binaryToGray[0] N/A 12 ns N/A
🆕 binaryToGray[42] N/A 14 ns N/A
🆕 encode[65536] N/A 276.8 µs N/A
🆕 findHighestSetBit[1024] N/A 30 ns N/A
🆕 binaryToGray[255] N/A 14 ns N/A
🆕 encode[1024] N/A 4.2 µs N/A
🆕 grayToBinary[255] N/A 24 ns N/A
🆕 grayToBinary[1024] N/A 26 ns N/A
🆕 binaryToGray[1024] N/A 14 ns N/A
🆕 decode[1024] N/A 1.9 µs N/A
🆕 sudokuSolver N/A 174.4 µs N/A
🆕 isPowerOfTwo[42] N/A 14 ns N/A
🆕 decode[65536] N/A 189.8 µs N/A
🆕 findHighestSetBit[65535] N/A 35 ns N/A
🆕 countSetBits[0] N/A 14 ns N/A
🆕 binaryToGray[65535] N/A 14 ns N/A
🆕 generateCombinations[5] N/A 4.4 µs N/A
🆕 grayToBinary[42] N/A 20 ns N/A
🆕 generateCombinations[9] N/A 29.5 µs N/A
🆕 isPowerOfTwo[0] N/A 14 ns N/A
... ... ... ... ...

ℹ️ Only the first 20 benchmarks are displayed. Go to the app to view all benchmarks.


Comparing cod-2309-walltime-benchmarks-with-flamegraphs (b43be0b) with cod-2308-walltime-benchmarks-without-flamegraphs (fd966b0)

Open in CodSpeed

Footnotes

  1. 9 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@not-matthias not-matthias force-pushed the cod-2309-walltime-benchmarks-with-flamegraphs branch 5 times, most recently from cf5f6ac to 14a4302 Compare March 13, 2026 18:45
@not-matthias not-matthias marked this pull request as ready for review March 13, 2026 18:48
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds CodSpeed-flavored benchmark URIs and introduces a non-inlined “root frame” wrapper in the JMH codegen to make Java walltime flamegraphs more usable, while reorganizing examples and CI to exercise the new behavior.

Changes:

  • Introduce io.codspeed.BenchmarkUri and propagate URI usage into result collection and instrumentation hooks.
  • Modify JMH generator to emit a non-inlined root-frame method and route benchmark calls through it.
  • Restructure examples under examples/ and update CI to run them (including walltime runs across multiple JDK distributions).

Reviewed changes

Copilot reviewed 29 out of 30 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
settings.gradle.kts Updates Gradle project include path to the new examples layout.
jmh-fork/jmh-core/src/main/java/io/codspeed/BenchmarkUri.java Adds URI construction + source file resolution logic.
jmh-fork/jmh-core/src/test/java/io/codspeed/BenchmarkUriTest.java Adds unit tests for URI pieces (bench name + source path fallback).
jmh-fork/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java Forces forks off when instrumented (for flamegraphs) and reports executed benchmark via URI.
jmh-fork/jmh-core/src/main/java/org/openjdk/jmh/runner/BaseRunner.java Starts/stops CodSpeed hooks for embedded runs and reports executed benchmark via URI.
jmh-fork/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java Emits a DONT_INLINE “root frame” wrapper and routes stub invocations through it.
jmh-fork/jmh-core/src/main/java/io/codspeed/result/CodSpeedResultCollector.java Stores URI alongside benchmark name in walltime results.
jmh-fork/jmh-core/build.gradle.kts Adds JUnit dependency for the new tests.
examples/example-gradle/** Adds new Gradle example project and benchmarks (incl. TheAlgorithms-Java sources).
examples/example-maven/** Adjusts Maven example layout and dependencies; adds a bench source link.
.github/workflows/ci.yml Updates paths, adds caches, and expands walltime job to test multiple JDK distributions + installs a custom runner.
.gitmodules Adds TheAlgorithms-Java submodule.
AGENTS.md / CLAUDE.md Adds repo agent guidance / indirection file.
Comments suppressed due to low confidence (1)

examples/example-maven/src/main/java/bench:1

  • This appears to be a symlink-style “link file” to a source directory. On Windows (and some CI setups), symlinks are often checked out as plain files, which would remove the bench/ directory from the compiler’s perspective and break the Maven example build. Prefer adding the shared benchmark sources via Maven configuration (e.g., add an additional source root pointing at ../example-gradle/src/jmh/java) rather than relying on symlink semantics.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

@not-matthias not-matthias force-pushed the cod-2309-walltime-benchmarks-with-flamegraphs branch from 0f6ed3e to 3dc349a Compare March 13, 2026 18:57
Copy link
Copy Markdown

@GuillaumeLagrange GuillaumeLagrange left a comment

Choose a reason for hiding this comment

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

ogltm to me

@not-matthias not-matthias force-pushed the cod-2309-walltime-benchmarks-with-flamegraphs branch from c559c2b to 7885910 Compare March 26, 2026 19:46
Prepares for MavenCentral publishing by using a unique group ID
(`io.codspeed.jmh` instead of `org.openjdk.jmh`) and dropping the
`-codspeed.N` version suffix.

Refs: COD-2400
Only show the "Running with CodSpeed" banner, write walltime results,
and restrict benchmark modes when actually running under CodSpeed
instrumentation. Restores standard JMH behavior when running locally.
@not-matthias not-matthias force-pushed the cod-2309-walltime-benchmarks-with-flamegraphs branch from 7885910 to eb1a958 Compare March 27, 2026 10:33
@not-matthias not-matthias force-pushed the cod-2309-walltime-benchmarks-with-flamegraphs branch from 00938ea to b43be0b Compare March 27, 2026 11:24
@not-matthias not-matthias deleted the branch cod-2308-walltime-benchmarks-without-flamegraphs March 27, 2026 13:40
@not-matthias
Copy link
Copy Markdown
Member Author

Github is drunk, the PR has been merged onto main but it didn't detect it for some reason (probably because the base branch was set to cod-2308(?), not sure)

@not-matthias not-matthias deleted the cod-2309-walltime-benchmarks-with-flamegraphs branch March 27, 2026 13:41
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.

3 participants