Repository navigation
Add oshi-benchmark module with JMH benchmarks comparing JNA and FFM - #3127
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📜 Recent review details⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
📝 WalkthroughWalkthroughAdds an Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
✨ Simplify code
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3127 +/- ##
==========================================
+ Coverage 66.42% 67.55% +1.13%
==========================================
Files 37 37
Lines 2034 2034
Branches 340 340
==========================================
+ Hits 1351 1374 +23
+ Misses 561 540 -21
+ Partials 122 120 -2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
oshi-benchmark/scripts/run-benchmarks.sh (1)
22-26: Consider adding a Java 25 preflight check for clearer failures.If run on older JDKs, Line 24/Line 25 can fail with reactor/module-selection errors; an early version check gives a direct message.
💡 Suggested preflight guard
cd "${REPO_ROOT}" JAR="${REPO_ROOT}/oshi-benchmark/target/benchmarks.jar" + +JAVA_MAJOR="$(java -version 2>&1 | awk -F[\".] '/version/ {print $2}')" +if [ "${JAVA_MAJOR}" -lt 25 ]; then + echo "ERROR: oshi-benchmark requires JDK 25+ (detected ${JAVA_MAJOR})." >&2 + exit 1 +fi if [ ! -f "${JAR}" ]; then🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@oshi-benchmark/scripts/run-benchmarks.sh` around lines 22 - 26, Add a Java 25 preflight check at the top of run-benchmarks.sh before the existing JAR build block (before the if [ ! -f "${JAR}" ] ... fi) to detect the runtime Java major version (from java -version or $JAVA_HOME) and exit with a clear error if the major version is less than 25; update the error message to reference the script name and required Java 25 so users see a direct, actionable failure instead of later reactor/module-selection errors when running the ./mvnw install/package commands.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@CHANGELOG.md`:
- Line 3: The "##### New Features" heading jumps levels and triggers MD001;
change that heading to the next level up (use "#### New Features") so it is one
level deeper than the release heading and no longer skips intermediate levels;
locate the "##### New Features" line and replace it with "#### New Features" to
satisfy markdownlint.
In `@oshi-benchmark/pom.xml`:
- Around line 100-102: Remove the unnecessary preview compiler argument by
deleting the <arg>--enable-preview</arg> entry inside the <compilerArgs> block
(the XML elements named compilerArgs and arg) in the Maven pom so the build no
longer passes --enable-preview to the compiler.
---
Nitpick comments:
In `@oshi-benchmark/scripts/run-benchmarks.sh`:
- Around line 22-26: Add a Java 25 preflight check at the top of
run-benchmarks.sh before the existing JAR build block (before the if [ ! -f
"${JAR}" ] ... fi) to detect the runtime Java major version (from java -version
or $JAVA_HOME) and exit with a clear error if the major version is less than 25;
update the error message to reference the script name and required Java 25 so
users see a direct, actionable failure instead of later reactor/module-selection
errors when running the ./mvnw install/package commands.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: f550f9a0-c5af-45d8-b81c-87c26c0eb433
📒 Files selected for processing (13)
CHANGELOG.mdREADME.mdconfig/checkstyle-suppressions.xmloshi-benchmark/pom.xmloshi-benchmark/scripts/run-benchmarks.shoshi-benchmark/src/main/java/oshi/benchmark/ProcessesBenchmark.javaoshi-core-java11/pom.xmloshi-core-java25/pom.xmloshi-core/pom.xmloshi-demo/pom.xmloshi-dist/pom.xmlpom.xmlsrc/site/markdown/index.md
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
- GitHub Check: Test JDK 25, macos-latest
- GitHub Check: Test JDK 11, windows-latest
- GitHub Check: Test JDK 21, windows-latest
- GitHub Check: Test JDK 21, ubuntu-latest
- GitHub Check: Test JDK 11, macos-latest
- GitHub Check: Test JDK 11, ubuntu-latest
- GitHub Check: Test JDK 25, windows-latest
- GitHub Check: Test JDK 25, ubuntu-latest
- GitHub Check: Analyze (java)
- GitHub Check: Test JDK 21, macos-latest
- GitHub Check: Codacy Static Code Analysis
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3121
File: oshi-core/src/main/java/oshi/software/os/linux/LinuxOperatingSystem.java:53-53
Timestamp: 2026-04-06T04:45:47.644Z
Learning: In the oshi/oshi project, the public API is strictly limited to interfaces and classes in the `oshi`, `oshi.hardware`, and `oshi.software.os` packages. All platform-specific code under subpackages like `oshi.software.os.linux`, `oshi.hardware.platform.linux`, etc., is considered implementation detail — not public API. Do not flag changes to platform-specific classes (e.g., making `LinuxOperatingSystem` abstract, narrowing constructor visibility, adding abstract methods) as public API breaks.
📚 Learning: 2026-03-29T20:01:06.452Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3014
File: oshi-core-java11/src/main/java/module-info.java:10-17
Timestamp: 2026-03-29T20:01:06.452Z
Learning: In the oshi project, `oshi-core-java25/src/main/java/module-info.java` intentionally does NOT export `oshi.util.platform.unix.freebsd`, `oshi.util.platform.unix.openbsd`, or `oshi.util.platform.unix.solaris`, because the FFM (Foreign Function & Memory) implementation only supports Windows, macOS, and Linux. This differs from `oshi-core-java11/src/main/java/module-info.java` which exports all Unix platform packages. The asymmetry is by design.
Applied to files:
oshi-core-java11/pom.xmloshi-core-java25/pom.xmlsrc/site/markdown/index.mdREADME.mdpom.xmloshi-benchmark/pom.xml
📚 Learning: 2026-04-06T04:45:47.644Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3121
File: oshi-core/src/main/java/oshi/software/os/linux/LinuxOperatingSystem.java:53-53
Timestamp: 2026-04-06T04:45:47.644Z
Learning: In the oshi/oshi project, the public API is strictly limited to interfaces and classes in the `oshi`, `oshi.hardware`, and `oshi.software.os` packages. All platform-specific code under subpackages like `oshi.software.os.linux`, `oshi.hardware.platform.linux`, etc., is considered implementation detail — not public API. Do not flag changes to platform-specific classes (e.g., making `LinuxOperatingSystem` abstract, narrowing constructor visibility, adding abstract methods) as public API breaks.
Applied to files:
oshi-core-java11/pom.xmloshi-core-java25/pom.xmloshi-core/pom.xmloshi-dist/pom.xmlsrc/site/markdown/index.mdREADME.mdpom.xmloshi-benchmark/pom.xml
🪛 markdownlint-cli2 (0.22.0)
CHANGELOG.md
[warning] 3-3: Heading levels should only increment by one level at a time
Expected: h2; Actual: h5
(MD001, heading-increment)
🔇 Additional comments (15)
config/checkstyle-suppressions.xml (1)
7-7: Benchmark suppression is consistent with existing policy.This follows the same suppression model already used for
demoand is appropriate for generated/experimental benchmark code paths.oshi-core-java11/pom.xml (1)
8-8: Parent version bump looks correct.This change cleanly aligns
oshi-core-java11with the new6.12.0-SNAPSHOTbaseline.oshi-core-java25/pom.xml (1)
8-8: Version alignment is good here.No concerns with updating the parent reference to
6.12.0-SNAPSHOT.oshi-dist/pom.xml (1)
8-8: LGTM on parent version update.This keeps
oshi-distaligned with the rest of the multi-module snapshot bump.oshi-demo/pom.xml (1)
8-8: Parent snapshot bump is correct.No issues with this module-level version alignment.
oshi-core/pom.xml (1)
8-8: Core module version bump is clean.This is consistent with the repository-wide move to
6.12.0-SNAPSHOT.CHANGELOG.md (1)
1-4: Release entry content is clear and correctly scoped.The new 6.12.0 section and PR reference read well and match the feature being introduced.
src/site/markdown/index.md (2)
53-55: Snapshot links are correctly version-aligned.These links now match the
6.12.0-SNAPSHOTproject versioning.
118-122: Benchmark documentation addition looks good.The new section is concise and gives a clear execution path for the JDK 25+ benchmark module.
README.md (2)
53-55: Snapshot version link update looks good.The version bump to
6.12.0-SNAPSHOTis consistent and clear in this section.
118-122: Benchmark usage docs are clear and actionable.The added benchmark description plus direct script invocation improves discoverability for the new module.
pom.xml (3)
7-7: Version bump is consistent.This aligns the parent POM with the new snapshot baseline.
709-713: RestrictImports exclusion for benchmark package is correctly scoped.This prevents false positives for JMH imports in benchmark sources while keeping restrictions intact elsewhere.
1000-1002: java25 profile module inclusion is correct.Adding
oshi-benchmarkhere matches the intended JDK 25+ build activation behavior.oshi-benchmark/src/main/java/oshi/benchmark/ProcessesBenchmark.java (1)
44-69: Solid JMH benchmark structure for apples-to-apples comparison.Setup scoping and paired benchmark methods are well-formed for comparing JNA vs FFM on the same API call.
…ight check - Remove unnecessary --enable-preview compiler arg from benchmark pom; no preview language features are used in ProcessesBenchmark - Add Java 25 version check to run-benchmarks.sh before attempting to build or run, with a clear actionable error message
Adds a new
oshi-benchmarkmodule (JDK 25+) providing JMH microbenchmarks to measure and compare the performance of JNA and FFM implementations side by side.Changes
oshi-benchmark/pom.xml: New module depending onoshi-core-java25as a compiled jar (same pattern asoshi-demo). Uses JMH 1.37,maven-shade-pluginto produce a self-containedbenchmarks.jar, and skips OSGi/forbiddenapis/surefire plugins that don't apply. Compiler configured withuseModulePath=falseand explicitannotationProcessorPathsto work around a JPMS/JMH annotation processor incompatibility. Includes a TODO noting thatoshi-corewill need to be added as a second dependency once the FFM module is split from the JNA module.oshi-benchmark/scripts/run-benchmarks.sh: Convenience script that auto-detects the repository root, builds the fat jar via./mvnwif not already present, and runs the benchmarks. Accepts JMH arguments (e.g. a benchmark class name) as pass-through parameters.ProcessesBenchmark.java: Side-by-side@Benchmarkmethodsjna()andffm()both callinggetProcesses()on their respectiveOperatingSysteminstances, initialized once in@Setup. Configured for 3 warmup × 2s and 5 measurement × 2s iterations, with--enable-native-access=ALL-UNNAMEDembedded in@Forkso no extra JVM flags are needed at the command line.config/checkstyle-suppressions.xml: Added suppression for[\\/]benchmark[\\/].*matching the existingdemosuppression pattern.pom.xml: Addedoshi-benchmarkto thejava25profile module list and to the enforcer's import exclusions.6.11.2-SNAPSHOT→6.12.0-SNAPSHOTacross all poms, README, index.md, and CHANGELOG (minor bump reflecting the new module addition).Initial benchmark results (macOS, JDK 25)
ProcessesBenchmark.ffmProcessesBenchmark.jnaFFM is approximately 4× faster than JNA for
getProcesses()on macOS.Summary by CodeRabbit
New Features
Chores