feat(jmh-fork): add perf-map JVMTI agent for source-aware JIT symbol resolution#7
feat(jmh-fork): add perf-map JVMTI agent for source-aware JIT symbol resolution#7not-matthias wants to merge 6 commits intomainfrom
Conversation
Merging this PR will degrade performance by 19.51%
Performance Changes
Comparing Footnotes
|
0220c52 to
02a8fe5
Compare
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds a Linux-only perf-map JVMTI agent that emits perf map entries with source-aware symbols (preferring absolute source paths resolved from the git root), plus Gradle wiring and integration tests to validate the generated perf map output.
Changes:
- Added native JVMTI agent (
libperf_map_agent.so) that listens to JIT code events and writes perf-map entries withpath::class::methodsymbols. - Added Java attach helper (
PerfMapAgent) and JUnit integration tests that launch a child JVM with the agent to validate output. - Updated
jmh-coreGradle build to compile/package the agent and updated CI to run the Gradle-based tests.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
jmh-fork/jmh-core/src/test/java/io/codspeed/perf_map_agent/PerfMapAgentTest.java |
Adds Linux-only integration tests that validate map file creation and basic line format/content. |
jmh-fork/jmh-core/src/main/java/io/codspeed/perf_map_agent/c/perf_map_agent.c |
Implements the JVMTI agent, source-path resolution via git root discovery + recursive search, and a thread-safe cache. |
jmh-fork/jmh-core/src/main/java/io/codspeed/perf_map_agent/PerfMapAgent.java |
Adds a small Java CLI/API for attaching the agent to a running JVM by PID. |
jmh-fork/jmh-core/build.gradle.kts |
Compiles the perf-map agent on Linux and includes it in resources. |
.github/workflows/ci.yml |
Switches CI test execution to Gradle and enables Gradle caching. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
15d9130 to
c61df2c
Compare
de2844f to
802ab83
Compare
…resolution Add a JVMTI agent that hooks CompiledMethodLoad events and writes /tmp/perf-<pid>.map with source file paths resolved from the git root. Key features: - Resolves project source files to absolute paths via git root discovery - Falls back to clean relative paths for JDK/dependency classes - Thread-safe source file cache with pthread_once for git root init - VMDeath callback flushes deferred CompiledMethodLoad events - Handles lambda/hidden class signatures ($$Lambda/0x...) correctly - Java attach wrapper (PerfMapAgent) for runtime agent loading Includes integration tests validating perf map format, source path resolution, and default map path behavior.
The Maven job couldn't run the perf-map agent integration tests because it doesn't build the native lib. Switch to Gradle which compiles the native agent and runs all CodSpeed tests in a single job.
…CodSpeed When running under CodSpeed (isInstrumented()), load the perf-map JVMTI agent into benchmark JVMs: - Forked JVMs (@fork 1+): inject -agentpath: into the fork command - Current VM (@fork 0): self-attach via the Attach API, relying on -Djdk.attach.allowAttachSelf=true set by the CodSpeed runner The native library is extracted from classpath resources once and cached. Silently skipped when not available (non-Linux, not built).
802ab83 to
eecaad1
Compare
…symbol resolution
Replace the hand-rolled gcc Exec tasks with Gradle's cpp-library plugin via two new nested subprojects (jmh-core:native-instrument-hooks and jmh-core:native-perf-map-agent). Each subproject owns its .c sources and — for instrument-hooks — the upstream submodule; jmh-core consumes their linkRelease outputs as resources bundled into jmh-core.jar. Notes: - Gradle 9.0 removed the c-library plugin; cpp-library is used with -x c to keep .c files compiling as C under g++. - cpp-library's source set filters for *.cpp/*.cc/*.c++, so .c files are added directly to the CppCompile task to bypass that filter. - The native subprojects are excluded from the shared maven-publish block; only jmh-core ships, with both .so files at its jar root.
b84d250 to
c7c19aa
Compare
Key features: