Repository navigation
Add FFM registry drivers for HKEY_PERFORMANCE_DATA - #3171
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 (20)
✅ Files skipped from review due to trivial changes (7)
🚧 Files skipped from review as they are similar to previous changes (7)
📜 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). (9)
🧰 Additional context used🧠 Learnings (10)📓 Common learnings📚 Learning: 2026-04-17T23:43:33.461ZApplied to files:
📚 Learning: 2026-03-29T20:03:00.830ZApplied to files:
📚 Learning: 2026-04-17T23:56:43.867ZApplied to files:
📚 Learning: 2026-04-18T03:18:03.725ZApplied to files:
📚 Learning: 2026-04-17T23:52:52.926ZApplied to files:
📚 Learning: 2026-04-03T02:07:47.621ZApplied to files:
📚 Learning: 2026-04-05T05:40:45.797ZApplied to files:
📚 Learning: 2026-04-10T22:44:36.786ZApplied to files:
📚 Learning: 2026-04-05T05:39:21.126ZApplied to files:
🔇 Additional comments (1)
📝 WalkthroughWalkthroughAdds FFM-based readers for HKEY_PERFORMANCE_DATA, extracts Process/Thread PerfCounterBlock POJOs into oshi-common and exports that package, updates JNA/FFM consumers to the shared types, and adds a JUnit comparison test validating registry vs perf-counter data paths. Changes
Sequence Diagram(s)sequenceDiagram
participant Test as RegistryComparisonTest
participant JNA as JNA Reader
participant FFM as FFM Reader
participant Util as HkeyPerformanceDataUtilFFM
participant Reg as Windows Registry
participant Parser as PERF_DATA_BLOCK Parser
Test->>JNA: buildProcessMapFromRegistry(null)
JNA->>Reg: Query perflib via JNA
Reg-->>JNA: Binary perf data
JNA->>JNA: Parse & build ProcessPerfCounterBlock map
JNA-->>Test: Process map
Test->>FFM: buildProcessMapFromRegistry(null)
FFM->>Util: readPerfDataFromRegistry("Process", enum)
Util->>Reg: Read HKEY_PERFORMANCE_DATA via FFM
Reg-->>Util: MemorySegment buffer
Util->>Parser: Walk PERF_DATA_BLOCK / objects / instances
Parser-->>Util: Per-instance counter maps + timestamps
Util-->>FFM: Triplet<List<Map>, perfTime100nSec, utcMillis>
FFM->>FFM: Build ProcessPerfCounterBlock map
FFM-->>Test: Process map
Test->>Test: Compare maps (overlap, exact/static fields, cumulative ≥, memory ratio, timing)
Estimated code review effort🎯 4 (Complex) | ⏱️ ~75 minutes Possibly related PRs
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❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #3171 +/- ##
==========================================
+ Coverage 58.29% 58.66% +0.36%
==========================================
Files 336 341 +5
Lines 17693 17923 +230
Branches 3130 3165 +35
==========================================
+ Hits 10314 10514 +200
Misses 5854 5854
- Partials 1525 1555 +30
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
oshi-core-java25/src/main/java/oshi/driver/windows/registry/HkeyPerformanceDataUtilFFM.java (1)
250-282: Consider addingRegCloseKey(HKEY_PERFORMANCE_DATA)to free cached buffers.Per Microsoft documentation, calling
RegCloseKey(HKEY_PERFORMANCE_DATA)after querying clears cached performance data and releases loaded performance DLLs. In long-running processes with frequent polling, skipping this can cause gradual memory accumulation. The current implementation (like the existing JNA version) does not call it, but since you're adding the parallel FFM path, this is an opportunity to address it here or in a follow-up for both implementations.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@oshi-core-java25/src/main/java/oshi/driver/windows/registry/HkeyPerformanceDataUtilFFM.java` around lines 250 - 282, The readPerfDataBuffer method currently queries HKEY_PERFORMANCE_DATA via RegQueryValueEx but never calls RegCloseKey(HKEY_PERFORMANCE_DATA), which leaves Windows' cached performance data and loaded DLLs resident; after finishing the registry query (both on success after the ERROR_MORE_DATA loop and on any early error or exception) call RegCloseKey(WinRegFFM.HKEY_PERFORMANCE_DATA) via the FFM binding (RegCloseKey) and handle/log non-success return codes, ensuring the call is performed in every exit path (normal return and in the catch block) so cached buffers are released.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@oshi-benchmark/src/test/java/oshi/comparison/RegistryComparisonTest.java`:
- Around line 117-131: The zero-value branch in assertWithinRatio incorrectly
treats the fractional ratio (e.g., 0.25) as an absolute byte limit, causing
valid transient zero reads to fail; change that branch to compare the nonZero
value against a small absolute byte tolerance instead (introduce a named
constant like ZERO_TOLERANCE_BYTES = 1024*1024 in the test class) and assert
nonZero <= ZERO_TOLERANCE_BYTES with the same descriptive message; keep all
other logic in assertWithinRatio unchanged.
In
`@oshi-core-java25/src/main/java/oshi/driver/windows/registry/HkeyPerformanceDataUtilFFM.java`:
- Around line 263-277: The retry loop in HkeyPerformanceDataUtilFFM that calls
RegQueryValueEx can exit with ret != ERROR_SUCCESS (e.g., ERROR_LOCK_FAILED) and
still return pPerfData; modify the method to validate ret after the resize loop
and handle non-success: if ret != ERROR_SUCCESS log an error including
objectName and ret, release or discard the allocated pPerfData (do not return
it) and return null; ensure the validation checks the final ret value from
RegQueryValueEx (the variable ret) before returning pPerfData.
In
`@oshi-core-java25/src/main/java/oshi/driver/windows/registry/ProcessPerformanceDataFFM.java`:
- Around line 104-108: The procName parameter is accepted but unused; update
both ProcessPerformanceData.buildProcessMapFromPerfCounters and
ProcessPerformanceDataFFM.buildProcessMapFromPerfCounters to mirror the thread
implementations by branching on Util.isBlank(procName) and calling the
appropriate query method (e.g., ProcessInformation.queryProcessCounters() vs
ProcessInformation.queryProcessCounters(procName) and
ProcessInformationFFM.queryProcessCounters() vs
ProcessInformationFFM.queryProcessCounters(procName)); if the filtered overloads
don’t exist, add them to ProcessInformation / ProcessInformationFFM, and update
the Javadoc to reflect that procName filters results.
---
Nitpick comments:
In
`@oshi-core-java25/src/main/java/oshi/driver/windows/registry/HkeyPerformanceDataUtilFFM.java`:
- Around line 250-282: The readPerfDataBuffer method currently queries
HKEY_PERFORMANCE_DATA via RegQueryValueEx but never calls
RegCloseKey(HKEY_PERFORMANCE_DATA), which leaves Windows' cached performance
data and loaded DLLs resident; after finishing the registry query (both on
success after the ERROR_MORE_DATA loop and on any early error or exception) call
RegCloseKey(WinRegFFM.HKEY_PERFORMANCE_DATA) via the FFM binding (RegCloseKey)
and handle/log non-success return codes, ensuring the call is performed in every
exit path (normal return and in the catch block) so cached buffers are released.
🪄 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: 9ce385ee-3ef3-4077-91ef-747a76987f06
📒 Files selected for processing (20)
CHANGELOG.mdoshi-benchmark/src/test/java/oshi/comparison/RegistryComparisonTest.javaoshi-common/src/main/java/module-info.javaoshi-common/src/main/java/oshi/driver/common/windows/registry/ProcessPerfCounterBlock.javaoshi-common/src/main/java/oshi/driver/common/windows/registry/ThreadPerfCounterBlock.javaoshi-common/src/main/java/oshi/driver/common/windows/registry/package-info.javaoshi-core-java25/src/main/java/oshi/driver/windows/registry/HkeyPerformanceDataUtilFFM.javaoshi-core-java25/src/main/java/oshi/driver/windows/registry/ProcessPerformanceDataFFM.javaoshi-core-java25/src/main/java/oshi/driver/windows/registry/ThreadPerformanceDataFFM.javaoshi-core-java25/src/main/java/oshi/ffm/windows/WinPerfFFM.javaoshi-core-java25/src/main/java/oshi/ffm/windows/WinRegFFM.javaoshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSProcessFFM.javaoshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOperatingSystemFFM.javaoshi-core/src/main/java/oshi/driver/windows/registry/ProcessPerformanceData.javaoshi-core/src/main/java/oshi/driver/windows/registry/ThreadPerformanceData.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcess.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcessJNA.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOSThread.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOperatingSystem.javaoshi-core/src/test/java/oshi/driver/windows/registry/RegistryDriversTest.java
📜 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). (5)
- GitHub Check: Codacy Static Code Analysis
- GitHub Check: Test JDK 25, windows-latest (+ JNA==FFM)
- GitHub Check: Test JDK 25, macos-latest (+ JNA==FFM)
- GitHub Check: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)
- GitHub Check: Analyze (java)
🧰 Additional context used
🧠 Learnings (13)
📓 Common learnings
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3168
File: oshi-core-java25/src/main/java/oshi/ffm/windows/PdhFFM.java:0-0
Timestamp: 2026-04-17T23:43:33.461Z
Learning: In `oshi-core-java25/src/main/java/oshi/ffm/windows/PdhFFM.java`, the `PDH_RAW_COUNTER_LAYOUT` Java FFM struct layout must place `FirstValue` at byte offset 16 (not 12). The native MSVC compiler inserts 4 bytes of implicit alignment padding before the `LONGLONG FirstValue` field (after CStatus=4 bytes + FILETIME TimeStamp=8 bytes = 12 bytes), because LONGLONG requires 8-byte alignment. The total struct size is 40 bytes (with trailing padding). Do not use JAVA_LONG_UNALIGNED without explicit padding here, as that incorrectly places FirstValue at offset 12 and causes reads of garbage counter values.
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3170
File: oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.java:177-183
Timestamp: 2026-04-18T03:18:03.725Z
Learning: In `oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.java`, GPU engine PDH instance counts (from `GpuInformationJNA.queryGpuEngineCounters()` / `GpuInformationFFM.queryGpuEngineCounters()`) are highly volatile — counts can differ dramatically (e.g., 53 vs 40) even between queries taken milliseconds apart. Do not assert instance count equality or exact instance list matching between JNA and FFM results. The only reliable assertion is that both are empty or both are non-empty (`assertThat(ffm.getA().isEmpty()).isEqualTo(jna.getA().isEmpty())`).
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3014
File: oshi-core-java25/src/main/java/oshi/util/platform/windows/PdhUtilFFM.java:87-89
Timestamp: 2026-03-29T20:03:00.830Z
Learning: In the OSHI FFM codebase (oshi-core-java25), all PDH/Kernel32/COM wrapper methods in classes like PdhFFM, Kernel32FFM, etc. declare `throws Throwable` solely as a compiler artifact of `MethodHandle.invokeExact`. They are native calls and do not throw Java checked exceptions in practice. The enclosing `getOpenFileDescriptors()` method in PdhUtilFFM already has an outer `catch (Throwable t)` that covers the entire method body including any `finally` blocks, so no exception-masking concern exists for cleanup calls like `PdhCloseQuery` in `finally`.
📚 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-common/src/main/java/module-info.javaoshi-common/src/main/java/oshi/driver/common/windows/registry/package-info.javaoshi-core-java25/src/main/java/oshi/ffm/windows/WinRegFFM.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOSThread.java
📚 Learning: 2026-04-06T04:45:51.516Z
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:51.516Z
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-common/src/main/java/module-info.java
📚 Learning: 2026-04-12T19:22:09.716Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3149
File: oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacCentralProcessor.java:159-163
Timestamp: 2026-04-12T19:22:09.716Z
Learning: When reviewing OSHI hardware platform code that uses or implements `CentralProcessor`/`PhysicalProcessor.getEfficiency()`, remember the API’s counterintuitive semantics: a *higher* efficiency-class value indicates *greater performance* (lower efficiency). P-cores/“performance cores” should therefore have higher values (e.g., 1) than E-cores/“efficiency cores” (e.g., 0), as documented in the `CentralProcessor` Javadoc. Do not flag code as incorrect solely because ARM_P_CORES or Intel P-cores are assigned higher efficiency values.
Applied to files:
oshi-common/src/main/java/module-info.javaoshi-common/src/main/java/oshi/driver/common/windows/registry/package-info.javaoshi-common/src/main/java/oshi/driver/common/windows/registry/ThreadPerfCounterBlock.javaoshi-common/src/main/java/oshi/driver/common/windows/registry/ProcessPerfCounterBlock.java
📚 Learning: 2026-04-17T23:43:33.461Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3168
File: oshi-core-java25/src/main/java/oshi/ffm/windows/PdhFFM.java:0-0
Timestamp: 2026-04-17T23:43:33.461Z
Learning: In `oshi-core-java25/src/main/java/oshi/ffm/windows/PdhFFM.java`, the `PDH_RAW_COUNTER_LAYOUT` Java FFM struct layout must place `FirstValue` at byte offset 16 (not 12). The native MSVC compiler inserts 4 bytes of implicit alignment padding before the `LONGLONG FirstValue` field (after CStatus=4 bytes + FILETIME TimeStamp=8 bytes = 12 bytes), because LONGLONG requires 8-byte alignment. The total struct size is 40 bytes (with trailing padding). Do not use JAVA_LONG_UNALIGNED without explicit padding here, as that incorrectly places FirstValue at offset 12 and causes reads of garbage counter values.
Applied to files:
oshi-core-java25/src/main/java/oshi/ffm/windows/WinRegFFM.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOperatingSystem.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOSThread.javaoshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOperatingSystemFFM.javaoshi-common/src/main/java/oshi/driver/common/windows/registry/ThreadPerfCounterBlock.javaoshi-common/src/main/java/oshi/driver/common/windows/registry/ProcessPerfCounterBlock.javaoshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSProcessFFM.javaoshi-core/src/main/java/oshi/driver/windows/registry/ThreadPerformanceData.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcessJNA.javaoshi-core/src/main/java/oshi/driver/windows/registry/ProcessPerformanceData.javaoshi-core-java25/src/main/java/oshi/ffm/windows/WinPerfFFM.javaoshi-core-java25/src/main/java/oshi/driver/windows/registry/HkeyPerformanceDataUtilFFM.javaoshi-core-java25/src/main/java/oshi/driver/windows/registry/ThreadPerformanceDataFFM.javaoshi-core-java25/src/main/java/oshi/driver/windows/registry/ProcessPerformanceDataFFM.javaoshi-benchmark/src/test/java/oshi/comparison/RegistryComparisonTest.java
📚 Learning: 2026-04-03T02:07:47.621Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3110
File: oshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacHWDiskStoreFFM.java:119-121
Timestamp: 2026-04-03T02:07:47.621Z
Learning: In OSHI’s Java FFM/API implementation classes (e.g., *FFM.java) that implement/override `updateAttributes()`, preserve the intentional failure-handling pattern: catch `Throwable` and return `false` without logging. `updateAttributes()` is a public API whose contract is to signal failure via the boolean return value, and callers rely on that return value (so emitting logs from this path is not desired and should not be introduced during review unless the method contract changes).
Applied to files:
oshi-core-java25/src/main/java/oshi/ffm/windows/WinRegFFM.javaoshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOperatingSystemFFM.javaoshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSProcessFFM.javaoshi-core-java25/src/main/java/oshi/ffm/windows/WinPerfFFM.javaoshi-core-java25/src/main/java/oshi/driver/windows/registry/HkeyPerformanceDataUtilFFM.javaoshi-core-java25/src/main/java/oshi/driver/windows/registry/ThreadPerformanceDataFFM.javaoshi-core-java25/src/main/java/oshi/driver/windows/registry/ProcessPerformanceDataFFM.java
📚 Learning: 2026-04-18T03:18:03.725Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3170
File: oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.java:177-183
Timestamp: 2026-04-18T03:18:03.725Z
Learning: In `oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.java`, GPU engine PDH instance counts (from `GpuInformationJNA.queryGpuEngineCounters()` / `GpuInformationFFM.queryGpuEngineCounters()`) are highly volatile — counts can differ dramatically (e.g., 53 vs 40) even between queries taken milliseconds apart. Do not assert instance count equality or exact instance list matching between JNA and FFM results. The only reliable assertion is that both are empty or both are non-empty (`assertThat(ffm.getA().isEmpty()).isEqualTo(jna.getA().isEmpty())`).
Applied to files:
oshi-core/src/test/java/oshi/driver/windows/registry/RegistryDriversTest.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOperatingSystem.javaoshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOperatingSystemFFM.javaoshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSProcessFFM.javaoshi-core/src/main/java/oshi/driver/windows/registry/ThreadPerformanceData.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcessJNA.javaoshi-core/src/main/java/oshi/driver/windows/registry/ProcessPerformanceData.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcess.javaoshi-core-java25/src/main/java/oshi/driver/windows/registry/HkeyPerformanceDataUtilFFM.javaoshi-core-java25/src/main/java/oshi/driver/windows/registry/ThreadPerformanceDataFFM.javaoshi-core-java25/src/main/java/oshi/driver/windows/registry/ProcessPerformanceDataFFM.javaoshi-benchmark/src/test/java/oshi/comparison/RegistryComparisonTest.java
📚 Learning: 2026-04-12T19:34:59.050Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3149
File: oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacCentralProcessor.java:159-163
Timestamp: 2026-04-12T19:34:59.050Z
Learning: The counterintuitive naming of `PhysicalProcessor.getEfficiency()` / `EfficiencyClass` in OSHI (where a higher value means MORE performance and LESS efficiency, so P-cores get higher values than E-cores) is intentionally inherited from Microsoft's `PROCESSOR_RELATIONSHIP.EfficiencyClass` Win32 API: "A core with a higher value for the efficiency class has intrinsically greater performance and less efficiency." OSHI follows this same convention for cross-platform consistency. Do not flag P-cores being assigned higher efficiency values as a bug.
Applied to files:
oshi-core/src/main/java/oshi/software/os/windows/WindowsOperatingSystem.java
📚 Learning: 2026-04-17T23:52:52.926Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3168
File: oshi-common/src/main/java/oshi/driver/common/windows/perfmon/LoadAverage.java:47-58
Timestamp: 2026-04-17T23:52:52.926Z
Learning: In `oshi-common/src/main/java/oshi/driver/common/windows/perfmon/LoadAverage.java`, the `stopDaemon()` / `startDaemon()` lifecycle pattern (both `public synchronized` instance methods on the same monitor) is intentionally safe: `stopDaemon()` sets `loadAvgThread = null` immediately after `interrupt()`, and `startDaemon()` checks `loadAvgThread != null` under the same lock. Since both methods are synchronized on `this`, they cannot run concurrently, so no double-sampler race is possible. Do not flag this pattern as a race condition.
Applied to files:
oshi-core/src/main/java/oshi/software/os/windows/WindowsOperatingSystem.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOSThread.javaoshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOperatingSystemFFM.javaoshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSProcessFFM.javaoshi-core/src/main/java/oshi/driver/windows/registry/ThreadPerformanceData.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcessJNA.javaoshi-core/src/main/java/oshi/driver/windows/registry/ProcessPerformanceData.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcess.java
📚 Learning: 2026-03-29T20:03:00.830Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3014
File: oshi-core-java25/src/main/java/oshi/util/platform/windows/PdhUtilFFM.java:87-89
Timestamp: 2026-03-29T20:03:00.830Z
Learning: In the OSHI FFM codebase (oshi-core-java25), all PDH/Kernel32/COM wrapper methods in classes like PdhFFM, Kernel32FFM, etc. declare `throws Throwable` solely as a compiler artifact of `MethodHandle.invokeExact`. They are native calls and do not throw Java checked exceptions in practice. The enclosing `getOpenFileDescriptors()` method in PdhUtilFFM already has an outer `catch (Throwable t)` that covers the entire method body including any `finally` blocks, so no exception-masking concern exists for cleanup calls like `PdhCloseQuery` in `finally`.
Applied to files:
oshi-core/src/main/java/oshi/software/os/windows/WindowsOperatingSystem.javaoshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOperatingSystemFFM.javaoshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSProcessFFM.javaoshi-core/src/main/java/oshi/driver/windows/registry/ThreadPerformanceData.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcessJNA.javaoshi-core-java25/src/main/java/oshi/ffm/windows/WinPerfFFM.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcess.javaoshi-core-java25/src/main/java/oshi/driver/windows/registry/HkeyPerformanceDataUtilFFM.javaoshi-core-java25/src/main/java/oshi/driver/windows/registry/ThreadPerformanceDataFFM.javaoshi-core-java25/src/main/java/oshi/driver/windows/registry/ProcessPerformanceDataFFM.java
📚 Learning: 2026-04-17T23:56:43.867Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3168
File: oshi-core-java25/src/main/java/oshi/util/platform/windows/PerfDataUtilFFM.java:287-298
Timestamp: 2026-04-17T23:56:43.867Z
Learning: In `oshi-core-java25/src/main/java/oshi/util/platform/windows/PerfDataUtilFFM.java`, the `queryWildcardCounters` method intentionally aborts and returns an empty Pair when any `addEnglishCounter` call fails. This is by design: the returned `Pair<List<String>, Map<T, List<Long>>>` requires strict parallel alignment between the instance list and each per-property value list. Aborting on failure preserves this alignment contract. This is different from `queryCounters` (non-wildcard), which gracefully skips individual failed counters since it returns a flat `Map<T, Long>` with no alignment constraint.
Applied to files:
oshi-core/src/main/java/oshi/software/os/windows/WindowsOperatingSystem.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOSThread.javaoshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOperatingSystemFFM.javaoshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSProcessFFM.javaoshi-core/src/main/java/oshi/driver/windows/registry/ThreadPerformanceData.javaoshi-core/src/main/java/oshi/driver/windows/registry/ProcessPerformanceData.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcess.javaoshi-core-java25/src/main/java/oshi/driver/windows/registry/HkeyPerformanceDataUtilFFM.javaoshi-core-java25/src/main/java/oshi/driver/windows/registry/ThreadPerformanceDataFFM.javaoshi-core-java25/src/main/java/oshi/driver/windows/registry/ProcessPerformanceDataFFM.javaoshi-benchmark/src/test/java/oshi/comparison/RegistryComparisonTest.java
📚 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, only interfaces and classes in the root packages `oshi`, `oshi.hardware`, and `oshi.software.os` are considered the public API. Code in subpackages that represent specific implementations/platforms (e.g., `oshi.software.os.linux`, `oshi.hardware.platform.linux`, and similar subpackages) is implementation detail. When reviewing, do not treat changes to classes in these platform-specific subpackages as public API breaks (for example: making `LinuxOperatingSystem` abstract, narrowing constructor visibility, or adding/removing abstract methods should not be flagged as breaking public API).
Applied to files:
oshi-core/src/main/java/oshi/software/os/windows/WindowsOperatingSystem.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOSThread.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcessJNA.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcess.java
📚 Learning: 2026-04-15T04:56:18.352Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3163
File: oshi-core-java25/src/test/java/oshi/ffm/mac/CoreFoundationTest.java:97-103
Timestamp: 2026-04-15T04:56:18.352Z
Learning: In CoreFoundationTest.java (oshi-core-java25/src/test/java/oshi/ffm/mac/CoreFoundationTest.java), asserting exact CFGetRetainCount deltas (+1 after retain, -1 after release) is intentional and considered reliable for freshly created CF objects (e.g., CFStringRef via CFStringRef.createCFString) where the test holds sole ownership. Do not flag these assertions as flaky — the Apple "avoid CFGetRetainCount" advisory applies to shared/framework-managed objects, not exclusively owned objects in unit tests.
Applied to files:
oshi-benchmark/src/test/java/oshi/comparison/RegistryComparisonTest.java
🔇 Additional comments (11)
oshi-core-java25/src/main/java/oshi/ffm/windows/WinRegFFM.java (1)
11-11: LGTM.HKEY_PERFORMANCE_DATA = 0x80000004Lmatches the Win32 predefined registry handle value.oshi-common/src/main/java/oshi/driver/common/windows/registry/package-info.java (1)
1-8: LGTM. Straightforward new package-info.oshi-common/src/main/java/oshi/driver/common/windows/registry/ThreadPerfCounterBlock.java (1)
13-118: LGTM. Straightforward extraction of the previously nestedPerfCounterBlockinto a shared immutable POJO; field set, constructor order, and getters match both existing call sites inThreadPerformanceData(snippets show all 11 args populated in the same order).CHANGELOG.md (1)
35-35: LGTM. Entry accurately summarizes the PR.oshi-common/src/main/java/module-info.java (1)
25-25: LGTM. New package export is consistent with the relocated POJOs being consumed by bothoshi-coreandoshi-core-java25.oshi-core/src/test/java/oshi/driver/windows/registry/RegistryDriversTest.java (1)
21-39: LGTM. Type switch to the shared POJOs is mechanical and matches the new return types ofbuild{Process,Thread}MapFromRegistry.oshi-core/src/main/java/oshi/software/os/windows/WindowsOperatingSystem.java (1)
51-343: LGTM. Mechanical retyping to the new common POJOs; no behavioral change. All Supplier/Map generics,processMapToListlocals, and static query return types are consistently updated.oshi-core/src/main/java/oshi/software/os/windows/WindowsOSThread.java (1)
21-151: LGTM. Constructor,updateAttributessignatures, and thebuildThreadMapFromPerfCountersmap generic all correctly updated toThreadPerfCounterBlock. Consistent withWindowsOSProcess.getThreadDetails()/queryMatchingThreads()call sites in the provided snippets.oshi-core-java25/src/main/java/oshi/ffm/windows/WinPerfFFM.java (1)
57-60: Verify the struct layout against actual Windows header files with explicit pragma pack settings.The proposed change correctly moves
SystemTimeto offset 36, but both current and proposed layouts placePerfTimeat offset 56 when native documentation shows it at offset 52. Confirm whetherwinperf.huses#pragma pack(4),#pragma pack(1), or default alignment, as this affects whether explicit padding is needed and where. The PDH learning indicates MSVC inserts implicit padding beforeLONGLONGfields, but native offsets suggest no gap betweenSystemTimeandPerfTime—these need to be reconciled before applying the fix.oshi-benchmark/src/test/java/oshi/comparison/RegistryComparisonTest.java (1)
96-96: This assertion is valid. Both ThreadPerformanceData (JNA) and ThreadPerformanceDataFFM use identical pointer normalization: they check the data type and either cast directly to(Long)for 64-bit values or applyInteger.toUnsignedLong((Integer) addr)for 32-bit integers. No divergence in normalization exists between the two paths, so exact equality comparison is appropriate.oshi-core-java25/src/main/java/oshi/driver/windows/registry/ThreadPerformanceDataFFM.java (1)
131-132: No issue found — FFM implementation matches JNA semantics.The FFM registry path uses
ParseUtil.filetimeToUtcMs(startTime, false), which is correct. JNA's registry path does not usefiletimeToUtcMsat all; instead it usesFILETIME.filetimeToDate().getTime(), which performs the same UTC conversion without applying a timezone offset. Both approaches treat registry filetimes as already in UTC and do not applyTZ_OFFSET. Thelocal=trueflag infiletimeToUtcMsis used only for the PDH counter path (viaPerfDataUtil), not the registry path. The FFM implementation is consistent with the JNA baseline.> Likely an incorrect or invalid review comment.
| public static Map<Integer, ProcessPerfCounterBlock> buildProcessMapFromPerfCounters(Collection<Integer> pids, | ||
| String procName) { | ||
| Map<Integer, ProcessPerfCounterBlock> processMap = new HashMap<>(); | ||
| Pair<List<String>, Map<ProcessPerformanceProperty, List<Long>>> instanceValues = ProcessInformationFFM | ||
| .queryProcessCounters(); |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Check JNA baseline and available ProcessInformationFFM query methods.
rg -nP -C3 '\bqueryProcessCounters\s*\(' --type=java
rg -nP -C5 'buildProcessMapFromPerfCounters\s*\(' --type=java -g '!**/ProcessPerformanceDataFFM.java'Repository: oshi/oshi
Length of output: 15963
🏁 Script executed:
#!/bin/bash
# Get full method implementation for JNA version
sed -n '104,150p' oshi-core/src/main/java/oshi/driver/windows/registry/ProcessPerformanceData.java
# Get full method implementation for FFM version
sed -n '104,150p' oshi-core-java25/src/main/java/oshi/driver/windows/registry/ProcessPerformanceDataFFM.java
# Check ThreadPerformanceData for comparison
rg -n 'buildThreadMapFromPerfCounters' oshi-core/src/main/java/oshi/driver/windows/registry/ProcessPerformanceData.java -A 2
rg -n 'buildThreadMapFromPerfCounters' oshi-core-java25/src/main/java/oshi/driver/windows/registry/ThreadPerformanceDataFFM.java -A 2Repository: oshi/oshi
Length of output: 5759
🏁 Script executed:
#!/bin/bash
# Get full ThreadPerformanceDataFFM implementation to see if it uses procName
sed -n '105,160p' oshi-core-java25/src/main/java/oshi/driver/windows/registry/ThreadPerformanceDataFFM.java
# Also check ThreadPerformanceData (JNA) for comparison
sed -n '105,160p' oshi-core/src/main/java/oshi/driver/windows/registry/ThreadPerformanceData.javaRepository: oshi/oshi
Length of output: 6587
procName parameter is unused in both JNA and FFM versions; unlike ThreadPerformanceData.buildThreadMapFromPerfCounters(), which branches on procName to select query methods, the process counterpart does not.
The method accepts procName and Javadoc states "Filter by this process name", but neither ProcessPerformanceData (JNA) nor ProcessPerformanceDataFFM use it—both only filter by pids. This is inconsistent with the thread performance data methods (ThreadPerformanceData.buildThreadMapFromPerfCounters() and ThreadPerformanceDataFFM.buildThreadMapFromPerfCounters()), which correctly branch on Util.isBlank(procName) to call either unfiltered or filtered query methods.
Either wire procName through both implementations to match the thread pattern, or remove it from both signatures.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In
`@oshi-core-java25/src/main/java/oshi/driver/windows/registry/ProcessPerformanceDataFFM.java`
around lines 104 - 108, The procName parameter is accepted but unused; update
both ProcessPerformanceData.buildProcessMapFromPerfCounters and
ProcessPerformanceDataFFM.buildProcessMapFromPerfCounters to mirror the thread
implementations by branching on Util.isBlank(procName) and calling the
appropriate query method (e.g., ProcessInformation.queryProcessCounters() vs
ProcessInformation.queryProcessCounters(procName) and
ProcessInformationFFM.queryProcessCounters() vs
ProcessInformationFFM.queryProcessCounters(procName)); if the filtered overloads
don’t exist, add them to ProcessInformation / ProcessInformationFFM, and update
the Javadoc to reflect that procName filters results.
da41bd2 to
c6284eb
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
oshi-core-java25/src/main/java/oshi/driver/windows/registry/HkeyPerformanceDataUtilFFM.java (1)
85-170: Precomputed counter-index map fromgetCounterIndicesis discarded — re-resolved per instance × counter inside the loop.
getCounterIndices(...)at Line 89 returns aPair<Integer, EnumMap<T, Integer>>whose second element is an already-validated enum→counter-index map, but the caller uses the Pair only for its null check. Then Line 170 re-resolvesCOUNTER_INDEX_MAP.get(key.getCounter())for every(instance, counter)pair, which for e.g.Process/Threadwith hundreds of instances and ~10 counters is a lot of redundant lookups. Using the precomputedEnumMapis both faster and avoids a second independent validation path.♻️ Proposed refactor
- Pair<Integer, EnumMap<T, Integer>> indices = getCounterIndices(objectName, counterEnum); - if (indices == null) { + Pair<Integer, EnumMap<T, Integer>> indices = getCounterIndices(objectName, counterEnum); + if (indices == null) { return null; } + int objectIndex = indices.getA(); + EnumMap<T, Integer> keyToCounterIndex = indices.getB();Then replace Line 127:
- if (objectNameTitleIndex == COUNTER_INDEX_MAP.get(objectName).intValue()) { + if (objectNameTitleIndex == objectIndex) {And replace Line 170:
- int keyIndex = COUNTER_INDEX_MAP.get(key.getCounter()); + int keyIndex = keyToCounterIndex.get(key);🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@oshi-core-java25/src/main/java/oshi/driver/windows/registry/HkeyPerformanceDataUtilFFM.java` around lines 85 - 170, The readPerfDataFromRegistry method currently discards the EnumMap returned by getCounterIndices and repeatedly calls the global COUNTER_INDEX_MAP.get(...) inside the per-instance/per-counter loop; change the method to extract the Pair<Integer, EnumMap<T,Integer>> result (use the Pair's second element) into a local EnumMap<String,Integer> (or EnumMap<T,Integer>) immediately after getCounterIndices, and then replace the per-counter lookup COUNTER_INDEX_MAP.get(key.getCounter()) with a lookup in that local EnumMap (using the enum key or its counter id as appropriate) so the validated, precomputed mapping from getCounterIndices is reused for counterOffsets and sizes throughout readPerfDataFromRegistry.oshi-core-java25/src/main/java/oshi/driver/windows/registry/ThreadPerformanceDataFFM.java (1)
131-147: Stale comment doesn't match the code.Lines 144-145 claim "if creation time value is less than current millis, it's in 1970 epoch, otherwise it's 1601 epoch and we must convert", but the code at Line 132 unconditionally converts via
ParseUtil.filetimeToUtcMs(startTime, false)and then only clampsstartTime > now. The comment was copy-pasted from the Process variant (where it matches theif (ctime > now)branch) but doesn't apply here. Suggest deleting or rewording.🧹 Proposed tidy
- - // if creation time value is less than current millis, it's in 1970 epoch, - // otherwise it's 1601 epoch and we must convert threadMap.put(tid, new ThreadPerfCounterBlock(name, tid, pid, startTime, user, kernel, priority, threadState, threadWaitReason, startAddr, contextSwitches));🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@oshi-core-java25/src/main/java/oshi/driver/windows/registry/ThreadPerformanceDataFFM.java` around lines 131 - 147, The inline comment about epoch conversion is stale and misleading: update or remove it near the startTime handling in ThreadPerformanceDataFFM where startTime is set via ParseUtil.filetimeToUtcMs(startTime, false) and then clamped against now; ensure any remaining comment accurately reflects that startTime is always converted to UTC ms by ParseUtil.filetimeToUtcMs before being clamped and passed into the ThreadPerfCounterBlock stored in threadMap (i.e., delete the copy-pasted “1970 vs 1601 epoch” wording or replace it with a brief note that ParseUtil handles conversion and the subsequent clamp prevents future timestamps).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@oshi-benchmark/src/test/java/oshi/comparison/RegistryComparisonTest.java`:
- Around line 45-47: The assertion in RegistryComparisonTest.java currently uses
isGreaterThan(minSize * 9 / 10) which rejects exactly 90% when minSize is
divisible by 10; update the check for commonPids to require at least 90% by
computing the ceiling threshold (e.g., required = (minSize * 90 + 99) / 100 or
use a math ceil equivalent) and replace isGreaterThan(...) with
isGreaterThanOrEqualTo(required); apply the same change to the other two similar
assertions referenced around lines 88-90 (use the same ceiling calculation and
isGreaterThanOrEqualTo on commonPids compared to the computed required value).
---
Nitpick comments:
In
`@oshi-core-java25/src/main/java/oshi/driver/windows/registry/HkeyPerformanceDataUtilFFM.java`:
- Around line 85-170: The readPerfDataFromRegistry method currently discards the
EnumMap returned by getCounterIndices and repeatedly calls the global
COUNTER_INDEX_MAP.get(...) inside the per-instance/per-counter loop; change the
method to extract the Pair<Integer, EnumMap<T,Integer>> result (use the Pair's
second element) into a local EnumMap<String,Integer> (or EnumMap<T,Integer>)
immediately after getCounterIndices, and then replace the per-counter lookup
COUNTER_INDEX_MAP.get(key.getCounter()) with a lookup in that local EnumMap
(using the enum key or its counter id as appropriate) so the validated,
precomputed mapping from getCounterIndices is reused for counterOffsets and
sizes throughout readPerfDataFromRegistry.
In
`@oshi-core-java25/src/main/java/oshi/driver/windows/registry/ThreadPerformanceDataFFM.java`:
- Around line 131-147: The inline comment about epoch conversion is stale and
misleading: update or remove it near the startTime handling in
ThreadPerformanceDataFFM where startTime is set via
ParseUtil.filetimeToUtcMs(startTime, false) and then clamped against now; ensure
any remaining comment accurately reflects that startTime is always converted to
UTC ms by ParseUtil.filetimeToUtcMs before being clamped and passed into the
ThreadPerfCounterBlock stored in threadMap (i.e., delete the copy-pasted “1970
vs 1601 epoch” wording or replace it with a brief note that ParseUtil handles
conversion and the subsequent clamp prevents future timestamps).
🪄 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: e1b53279-34ce-4bba-bb53-c9e88ebbed0b
📒 Files selected for processing (20)
CHANGELOG.mdoshi-benchmark/src/test/java/oshi/comparison/RegistryComparisonTest.javaoshi-common/src/main/java/module-info.javaoshi-common/src/main/java/oshi/driver/common/windows/registry/ProcessPerfCounterBlock.javaoshi-common/src/main/java/oshi/driver/common/windows/registry/ThreadPerfCounterBlock.javaoshi-common/src/main/java/oshi/driver/common/windows/registry/package-info.javaoshi-core-java25/src/main/java/oshi/driver/windows/registry/HkeyPerformanceDataUtilFFM.javaoshi-core-java25/src/main/java/oshi/driver/windows/registry/ProcessPerformanceDataFFM.javaoshi-core-java25/src/main/java/oshi/driver/windows/registry/ThreadPerformanceDataFFM.javaoshi-core-java25/src/main/java/oshi/ffm/windows/WinPerfFFM.javaoshi-core-java25/src/main/java/oshi/ffm/windows/WinRegFFM.javaoshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSProcessFFM.javaoshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOperatingSystemFFM.javaoshi-core/src/main/java/oshi/driver/windows/registry/ProcessPerformanceData.javaoshi-core/src/main/java/oshi/driver/windows/registry/ThreadPerformanceData.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcess.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcessJNA.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOSThread.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOperatingSystem.javaoshi-core/src/test/java/oshi/driver/windows/registry/RegistryDriversTest.java
✅ Files skipped from review due to trivial changes (6)
- oshi-core-java25/src/main/java/oshi/ffm/windows/WinRegFFM.java
- oshi-common/src/main/java/oshi/driver/common/windows/registry/package-info.java
- oshi-common/src/main/java/module-info.java
- CHANGELOG.md
- oshi-common/src/main/java/oshi/driver/common/windows/registry/ThreadPerfCounterBlock.java
- oshi-common/src/main/java/oshi/driver/common/windows/registry/ProcessPerfCounterBlock.java
🚧 Files skipped from review as they are similar to previous changes (5)
- oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOperatingSystemFFM.java
- oshi-core/src/main/java/oshi/software/os/windows/WindowsOSThread.java
- oshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcessJNA.java
- oshi-core/src/main/java/oshi/driver/windows/registry/ProcessPerformanceData.java
- oshi-core-java25/src/main/java/oshi/ffm/windows/WinPerfFFM.java
📜 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)
- GitHub Check: Codacy Static Code Analysis
- GitHub Check: Test JDK 21, windows-latest
- GitHub Check: Test JDK 25, windows-latest (+ JNA==FFM)
- GitHub Check: Test JDK 25, macos-latest (+ JNA==FFM)
- GitHub Check: Test JDK 21, macos-latest
- GitHub Check: Test JDK 11, macos-latest
- GitHub Check: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)
- GitHub Check: Analyze (java)
🧰 Additional context used
🧠 Learnings (12)
📓 Common learnings
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3168
File: oshi-core-java25/src/main/java/oshi/ffm/windows/PdhFFM.java:0-0
Timestamp: 2026-04-17T23:43:33.461Z
Learning: In `oshi-core-java25/src/main/java/oshi/ffm/windows/PdhFFM.java`, the `PDH_RAW_COUNTER_LAYOUT` Java FFM struct layout must place `FirstValue` at byte offset 16 (not 12). The native MSVC compiler inserts 4 bytes of implicit alignment padding before the `LONGLONG FirstValue` field (after CStatus=4 bytes + FILETIME TimeStamp=8 bytes = 12 bytes), because LONGLONG requires 8-byte alignment. The total struct size is 40 bytes (with trailing padding). Do not use JAVA_LONG_UNALIGNED without explicit padding here, as that incorrectly places FirstValue at offset 12 and causes reads of garbage counter values.
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3170
File: oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.java:177-183
Timestamp: 2026-04-18T03:18:03.725Z
Learning: In `oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.java`, GPU engine PDH instance counts (from `GpuInformationJNA.queryGpuEngineCounters()` / `GpuInformationFFM.queryGpuEngineCounters()`) are highly volatile — counts can differ dramatically (e.g., 53 vs 40) even between queries taken milliseconds apart. Do not assert instance count equality or exact instance list matching between JNA and FFM results. The only reliable assertion is that both are empty or both are non-empty (`assertThat(ffm.getA().isEmpty()).isEqualTo(jna.getA().isEmpty())`).
📚 Learning: 2026-04-18T03:18:03.725Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3170
File: oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.java:177-183
Timestamp: 2026-04-18T03:18:03.725Z
Learning: In `oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.java`, GPU engine PDH instance counts (from `GpuInformationJNA.queryGpuEngineCounters()` / `GpuInformationFFM.queryGpuEngineCounters()`) are highly volatile — counts can differ dramatically (e.g., 53 vs 40) even between queries taken milliseconds apart. Do not assert instance count equality or exact instance list matching between JNA and FFM results. The only reliable assertion is that both are empty or both are non-empty (`assertThat(ffm.getA().isEmpty()).isEqualTo(jna.getA().isEmpty())`).
Applied to files:
oshi-core/src/test/java/oshi/driver/windows/registry/RegistryDriversTest.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOperatingSystem.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcess.javaoshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSProcessFFM.javaoshi-core-java25/src/main/java/oshi/driver/windows/registry/ProcessPerformanceDataFFM.javaoshi-benchmark/src/test/java/oshi/comparison/RegistryComparisonTest.javaoshi-core-java25/src/main/java/oshi/driver/windows/registry/ThreadPerformanceDataFFM.javaoshi-core-java25/src/main/java/oshi/driver/windows/registry/HkeyPerformanceDataUtilFFM.javaoshi-core/src/main/java/oshi/driver/windows/registry/ThreadPerformanceData.java
📚 Learning: 2026-04-17T23:52:52.926Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3168
File: oshi-common/src/main/java/oshi/driver/common/windows/perfmon/LoadAverage.java:47-58
Timestamp: 2026-04-17T23:52:52.926Z
Learning: In `oshi-common/src/main/java/oshi/driver/common/windows/perfmon/LoadAverage.java`, the `stopDaemon()` / `startDaemon()` lifecycle pattern (both `public synchronized` instance methods on the same monitor) is intentionally safe: `stopDaemon()` sets `loadAvgThread = null` immediately after `interrupt()`, and `startDaemon()` checks `loadAvgThread != null` under the same lock. Since both methods are synchronized on `this`, they cannot run concurrently, so no double-sampler race is possible. Do not flag this pattern as a race condition.
Applied to files:
oshi-core/src/main/java/oshi/software/os/windows/WindowsOperatingSystem.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcess.javaoshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSProcessFFM.javaoshi-core-java25/src/main/java/oshi/driver/windows/registry/ThreadPerformanceDataFFM.javaoshi-core/src/main/java/oshi/driver/windows/registry/ThreadPerformanceData.java
📚 Learning: 2026-03-29T20:03:00.830Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3014
File: oshi-core-java25/src/main/java/oshi/util/platform/windows/PdhUtilFFM.java:87-89
Timestamp: 2026-03-29T20:03:00.830Z
Learning: In the OSHI FFM codebase (oshi-core-java25), all PDH/Kernel32/COM wrapper methods in classes like PdhFFM, Kernel32FFM, etc. declare `throws Throwable` solely as a compiler artifact of `MethodHandle.invokeExact`. They are native calls and do not throw Java checked exceptions in practice. The enclosing `getOpenFileDescriptors()` method in PdhUtilFFM already has an outer `catch (Throwable t)` that covers the entire method body including any `finally` blocks, so no exception-masking concern exists for cleanup calls like `PdhCloseQuery` in `finally`.
Applied to files:
oshi-core/src/main/java/oshi/software/os/windows/WindowsOperatingSystem.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcess.javaoshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSProcessFFM.javaoshi-core-java25/src/main/java/oshi/driver/windows/registry/ProcessPerformanceDataFFM.javaoshi-core-java25/src/main/java/oshi/driver/windows/registry/ThreadPerformanceDataFFM.javaoshi-core-java25/src/main/java/oshi/driver/windows/registry/HkeyPerformanceDataUtilFFM.javaoshi-core/src/main/java/oshi/driver/windows/registry/ThreadPerformanceData.java
📚 Learning: 2026-04-17T23:56:43.867Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3168
File: oshi-core-java25/src/main/java/oshi/util/platform/windows/PerfDataUtilFFM.java:287-298
Timestamp: 2026-04-17T23:56:43.867Z
Learning: In `oshi-core-java25/src/main/java/oshi/util/platform/windows/PerfDataUtilFFM.java`, the `queryWildcardCounters` method intentionally aborts and returns an empty Pair when any `addEnglishCounter` call fails. This is by design: the returned `Pair<List<String>, Map<T, List<Long>>>` requires strict parallel alignment between the instance list and each per-property value list. Aborting on failure preserves this alignment contract. This is different from `queryCounters` (non-wildcard), which gracefully skips individual failed counters since it returns a flat `Map<T, Long>` with no alignment constraint.
Applied to files:
oshi-core/src/main/java/oshi/software/os/windows/WindowsOperatingSystem.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcess.javaoshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSProcessFFM.javaoshi-core-java25/src/main/java/oshi/driver/windows/registry/ProcessPerformanceDataFFM.javaoshi-benchmark/src/test/java/oshi/comparison/RegistryComparisonTest.javaoshi-core-java25/src/main/java/oshi/driver/windows/registry/ThreadPerformanceDataFFM.javaoshi-core-java25/src/main/java/oshi/driver/windows/registry/HkeyPerformanceDataUtilFFM.javaoshi-core/src/main/java/oshi/driver/windows/registry/ThreadPerformanceData.java
📚 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, only interfaces and classes in the root packages `oshi`, `oshi.hardware`, and `oshi.software.os` are considered the public API. Code in subpackages that represent specific implementations/platforms (e.g., `oshi.software.os.linux`, `oshi.hardware.platform.linux`, and similar subpackages) is implementation detail. When reviewing, do not treat changes to classes in these platform-specific subpackages as public API breaks (for example: making `LinuxOperatingSystem` abstract, narrowing constructor visibility, or adding/removing abstract methods should not be flagged as breaking public API).
Applied to files:
oshi-core/src/main/java/oshi/software/os/windows/WindowsOperatingSystem.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcess.java
📚 Learning: 2026-04-17T23:43:33.461Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3168
File: oshi-core-java25/src/main/java/oshi/ffm/windows/PdhFFM.java:0-0
Timestamp: 2026-04-17T23:43:33.461Z
Learning: In `oshi-core-java25/src/main/java/oshi/ffm/windows/PdhFFM.java`, the `PDH_RAW_COUNTER_LAYOUT` Java FFM struct layout must place `FirstValue` at byte offset 16 (not 12). The native MSVC compiler inserts 4 bytes of implicit alignment padding before the `LONGLONG FirstValue` field (after CStatus=4 bytes + FILETIME TimeStamp=8 bytes = 12 bytes), because LONGLONG requires 8-byte alignment. The total struct size is 40 bytes (with trailing padding). Do not use JAVA_LONG_UNALIGNED without explicit padding here, as that incorrectly places FirstValue at offset 12 and causes reads of garbage counter values.
Applied to files:
oshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcess.javaoshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSProcessFFM.javaoshi-core-java25/src/main/java/oshi/driver/windows/registry/ProcessPerformanceDataFFM.javaoshi-benchmark/src/test/java/oshi/comparison/RegistryComparisonTest.javaoshi-core-java25/src/main/java/oshi/driver/windows/registry/ThreadPerformanceDataFFM.javaoshi-core-java25/src/main/java/oshi/driver/windows/registry/HkeyPerformanceDataUtilFFM.javaoshi-core/src/main/java/oshi/driver/windows/registry/ThreadPerformanceData.java
📚 Learning: 2026-04-03T02:07:47.621Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3110
File: oshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacHWDiskStoreFFM.java:119-121
Timestamp: 2026-04-03T02:07:47.621Z
Learning: In OSHI’s Java FFM/API implementation classes (e.g., *FFM.java) that implement/override `updateAttributes()`, preserve the intentional failure-handling pattern: catch `Throwable` and return `false` without logging. `updateAttributes()` is a public API whose contract is to signal failure via the boolean return value, and callers rely on that return value (so emitting logs from this path is not desired and should not be introduced during review unless the method contract changes).
Applied to files:
oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSProcessFFM.javaoshi-core-java25/src/main/java/oshi/driver/windows/registry/ProcessPerformanceDataFFM.javaoshi-core-java25/src/main/java/oshi/driver/windows/registry/ThreadPerformanceDataFFM.javaoshi-core-java25/src/main/java/oshi/driver/windows/registry/HkeyPerformanceDataUtilFFM.java
📚 Learning: 2026-04-05T05:40:45.797Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3117
File: oshi-core-java25/src/main/java/oshi/hardware/platform/linux/LinuxPowerSourceFFM.java:62-65
Timestamp: 2026-04-05T05:40:45.797Z
Learning: In OSHI's Linux FFM and JNA udev code, a null guard on `udev_enumerate_new()` is intentionally absent and should not be flagged. This is consistent across all four FFM classes (LinuxPowerSourceFFM, LinuxHWDiskStoreFFM, LinuxLogicalVolumeGroupFFM, LinuxUsbDeviceFFM) and the JNA implementation (which also does not guard `enumerateNew()` for null). Per libudev semantics, `udev_enumerate_new()` only returns NULL when udev itself is broken (e.g. OOM), so a successful `udev_new()` (which is guarded) implies `udev_enumerate_new()` will succeed. Adding a null guard would be both redundant and inconsistent with the established pattern.
Applied to files:
oshi-core-java25/src/main/java/oshi/driver/windows/registry/ProcessPerformanceDataFFM.java
📚 Learning: 2026-04-10T22:44:36.786Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3136
File: oshi-core-java25/src/main/java/oshi/software/os/linux/LinuxOperatingSystemFFM.java:46-53
Timestamp: 2026-04-10T22:44:36.786Z
Learning: In OSHI's `AuxvFFM.queryAuxv()` (oshi-core-java25/src/main/java/oshi/driver/linux/proc/AuxvFFM.java), the do-while loop is safe even when `/proc/self/auxv` cannot be read: `FileUtil.readAllBytesAsBuffer` returns an empty ByteBuffer on failure, and `FileUtil.readLongFromBuffer`/`readIntFromBuffer` return 0L when reading past the buffer limit. This 0L equals AT_NULL, causing the loop to exit immediately with an empty map, which triggers the `getconf`/hardcoded-default fallback in callers like `LinuxOperatingSystemFFM`. Do not flag this do-while loop or the static initializer that calls `AuxvFFM.queryAuxv()` as unsafe.
Applied to files:
oshi-core-java25/src/main/java/oshi/driver/windows/registry/ProcessPerformanceDataFFM.javaoshi-core-java25/src/main/java/oshi/driver/windows/registry/HkeyPerformanceDataUtilFFM.java
📚 Learning: 2026-04-05T05:39:21.126Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3117
File: oshi-core-java25/src/main/java/oshi/hardware/platform/linux/LinuxPowerSourceFFM.java:62-65
Timestamp: 2026-04-05T05:39:21.126Z
Learning: In OSHI's Linux FFM/JNA udev code, a null guard on `udev_enumerate_new()` is unnecessary if `udev_new()` has already been guarded: per libudev semantics, `udev_enumerate_new()` only returns NULL when udev itself is broken (e.g. OOM), so a successful `udev_new()` implies `udev_enumerate_new()` will succeed as well. Do not flag missing null checks on `udev_enumerate_new()` as an issue.
Applied to files:
oshi-core-java25/src/main/java/oshi/driver/windows/registry/ProcessPerformanceDataFFM.java
📚 Learning: 2026-04-15T04:56:18.352Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3163
File: oshi-core-java25/src/test/java/oshi/ffm/mac/CoreFoundationTest.java:97-103
Timestamp: 2026-04-15T04:56:18.352Z
Learning: In CoreFoundationTest.java (oshi-core-java25/src/test/java/oshi/ffm/mac/CoreFoundationTest.java), asserting exact CFGetRetainCount deltas (+1 after retain, -1 after release) is intentional and considered reliable for freshly created CF objects (e.g., CFStringRef via CFStringRef.createCFString) where the test holds sole ownership. Do not flag these assertions as flaky — the Apple "avoid CFGetRetainCount" advisory applies to shared/framework-managed objects, not exclusively owned objects in unit tests.
Applied to files:
oshi-benchmark/src/test/java/oshi/comparison/RegistryComparisonTest.java
🔇 Additional comments (8)
oshi-core-java25/src/main/java/oshi/driver/windows/registry/HkeyPerformanceDataUtilFFM.java (1)
263-281: Finalretvalidation after resize loop is already present.The post-loop check at Lines 277-280 now handles non-
ERROR_SUCCESSexit from the resize loop. The earlier concern is addressed.oshi-core-java25/src/main/java/oshi/driver/windows/registry/ProcessPerformanceDataFFM.java (1)
96-108:procNameparameter still accepted but unused.The two-arg overload at Line 104 and the Javadoc at Line 100 imply filtering by process name, but
procNameis never passed toProcessInformationFFM.queryProcessCounters()nor used for post-filtering. Behavior is identical to the single-arg overload. Either wire it through to a filteredqueryProcessCounters(procName)overload (matching the thread-side pattern inThreadPerformanceDataFFM.buildThreadMapFromPerfCounters) or drop the parameter and the JNA counterpart's parameter.oshi-core/src/main/java/oshi/driver/windows/registry/ThreadPerformanceData.java (1)
17-155: LGTM — mechanical type refactor to shared POJO.Constructor argument ordering on lines 81-82 and 154-155 matches the
ThreadPerfCounterBlockconstructor signature fromoshi-common(name, threadID, owningProcessID, startTime, userTime, kernelTime, priority, threadState, threadWaitReason, startAddress, contextSwitches).oshi-core/src/test/java/oshi/driver/windows/registry/RegistryDriversTest.java (1)
21-39: LGTM.Test-side type declarations match the new shared POJO types from
oshi.driver.common.windows.registry. Assertions remain semantically unchanged.oshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcess.java (1)
23-366: LGTM — signature/type migration to shared POJOs.
updateAttributes(pcb, wts)still guardspcb == nullbefore dereference; thread-state override viaTHREADWAITREASON == 5behavior is preserved.oshi-core/src/main/java/oshi/software/os/windows/WindowsOperatingSystem.java (1)
51-343: LGTM.Supplier memoization, fallback chain (registry → perfcounters), and
processMapToList(...)flow are unchanged in behavior; only the block value types were migrated to the shared POJOs.oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSProcessFFM.java (1)
41-90: LGTM.Constructor and
updateAttributes(...)signatures now align with the shared POJOs and propagate correctly throughsuper(...).oshi-core-java25/src/main/java/oshi/driver/windows/registry/ThreadPerformanceDataFFM.java (1)
39-83: LGTM — registry-path logic matches the JNA reference.Field extraction, uptime flooring to 1, 100-nsec → ms scaling, and the
addr instanceof Long ? … : Integer.toUnsignedLong(...)pointer-width handling all mirrorThreadPerformanceData.buildThreadMapFromRegistry(...).
c6284eb to
575c0f2
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (3)
oshi-common/src/main/java/oshi/driver/common/windows/registry/ProcessPerfCounterBlock.java (2)
12-13: Consider making the classfinal.
@Immutableis advisory; declaringProcessPerfCounterBlockfinalprevents subclasses from breaking immutability and matches the intent of the annotation.♻️ Proposed fix
`@Immutable` -public class ProcessPerfCounterBlock { +public final class ProcessPerfCounterBlock {🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@oshi-common/src/main/java/oshi/driver/common/windows/registry/ProcessPerfCounterBlock.java` around lines 12 - 13, The class marked `@Immutable`, ProcessPerfCounterBlock, should be declared final to prevent subclassing from breaking immutability; update the class declaration to add the final modifier on public class ProcessPerfCounterBlock (ensure no subclasses rely on extending it and adjust any tests/usages accordingly) so the intent of the annotation is enforced by the type system.
23-23:pageFaultsfield type is inconsistent with its getter and narrows native DWORDs.The field is
intbutgetPageFaults()returnslong; the counter is sourced from a nativeDWORD(4-byte unsigned) via(Integer) …PAGEFAULTSPERSECinProcessPerformanceData.buildProcessMapFromRegistryandpageFaultsList.get(inst).intValue()inbuildProcessMapFromPerfCounters. Once the raw counter exceedsInteger.MAX_VALUE(~2.1B) — reachable on long-running, memory-intensive processes — the value silently wraps to a negativeintand is sign-extended to a large negativelong, which also risks flaking the newassertThat(p.getPageFaults()).isGreaterThanOrEqualTo(r.getPageFaults())check inRegistryComparisonTest.Storing as
longend-to-end avoids the lossy narrowing without changing the public getter contract.♻️ Proposed fix
- private final int pageFaults; + private final long pageFaults; - public ProcessPerfCounterBlock(String name, int parentProcessID, int priority, long privateWorkingSetSize, - long workingSetSize, long startTime, long upTime, long bytesRead, long bytesWritten, int pageFaults) { + public ProcessPerfCounterBlock(String name, int parentProcessID, int priority, long privateWorkingSetSize, + long workingSetSize, long startTime, long upTime, long bytesRead, long bytesWritten, long pageFaults) {Corresponding call sites in
ProcessPerformanceData.javacan drop theintnarrowing and pass the value aslong(useInteger.toUnsignedLong(...)for the registry path since the raw value is an unsigned DWORD).Also applies to: 102-107
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@oshi-common/src/main/java/oshi/driver/common/windows/registry/ProcessPerfCounterBlock.java` at line 23, The pageFaults field in ProcessPerfCounterBlock is declared as int but getPageFaults() returns long and native DWORD counters can exceed Integer.MAX_VALUE; change the pageFaults field to long and update any constructors/assignments in ProcessPerfCounterBlock to accept a long, then update call sites in ProcessPerformanceData.buildProcessMapFromRegistry to pass Integer.toUnsignedLong((Integer) …PAGEFAULTSPERSEC) instead of narrowing to int and in buildProcessMapFromPerfCounters to stop using pageFaultsList.get(inst).intValue() (pass the value as a long), ensuring all types flow as long end-to-end to avoid signed narrowing/wraparound while keeping the public getter unchanged.oshi-core-java25/src/main/java/oshi/driver/windows/registry/HkeyPerformanceDataUtilFFM.java (1)
302-317:catch (NumberFormatException)is unreachable.
ParseUtil.parseIntOrDefault(...)already handles invalid numeric text internally by returning the default (0here), so noNumberFormatExceptioncan propagate out of thetryblock. If the intent is to guard against unexpected shapes (e.g. an odd-lengthcounterTextor a null array), handle that explicitly instead; otherwise this catch is dead code.♻️ Proposed fix
- private static Map<String, Integer> mapCounterIndicesFromRegistry() { - HashMap<String, Integer> indexMap = new HashMap<>(); - try { - String[] counterText = Advapi32UtilFFM.registryGetStringArray( - MemorySegment.ofAddress(WinRegFFM.HKEY_LOCAL_MACHINE), HKEY_PERFORMANCE_TEXT, COUNTER); - for (int i = 1; i < counterText.length; i += 2) { - int idx = ParseUtil.parseIntOrDefault(counterText[i - 1], 0); - if (idx > 0) { - indexMap.putIfAbsent(counterText[i], idx); - } - } - } catch (NumberFormatException nfe) { - // Unexpected to ever get this, but handling it anyway - LOG.error("Unable to parse English counter names in registry Perflib 009."); - } - return Collections.unmodifiableMap(indexMap); - } + private static Map<String, Integer> mapCounterIndicesFromRegistry() { + HashMap<String, Integer> indexMap = new HashMap<>(); + String[] counterText = Advapi32UtilFFM.registryGetStringArray( + MemorySegment.ofAddress(WinRegFFM.HKEY_LOCAL_MACHINE), HKEY_PERFORMANCE_TEXT, COUNTER); + for (int i = 1; i < counterText.length; i += 2) { + int idx = ParseUtil.parseIntOrDefault(counterText[i - 1], 0); + if (idx > 0) { + indexMap.putIfAbsent(counterText[i], idx); + } + } + return Collections.unmodifiableMap(indexMap); + }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@oshi-core-java25/src/main/java/oshi/driver/windows/registry/HkeyPerformanceDataUtilFFM.java` around lines 302 - 317, The catch(NumberFormatException) in mapCounterIndicesFromRegistry is dead since ParseUtil.parseIntOrDefault won't throw; remove that catch and instead explicitly validate the registry result: after calling Advapi32UtilFFM.registryGetStringArray (counterText) check for null and ensure counterText.length > 1, then iterate only up to counterText.length - 1 (so you never read past the end) and keep the existing ParseUtil.parseIntOrDefault usage and indexMap.putIfAbsent logic; preserve returning Collections.unmodifiableMap(indexMap).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@oshi-benchmark/src/test/java/oshi/comparison/RegistryComparisonTest.java`:
- Around line 60-63: The assertions fail when native cumulative counters wrap
because ProcessPerfCounterBlock.pageFaults and
ThreadPerfCounterBlock.contextSwitches are stored as int and only widened in
getters; change those POJO fields to long, update their getters
(getPageFaults(), getContextSwitches()) to return long, and adjust any
constructors/assignment sites that set those fields to use long values so the
stored value never loses precision; after this change the existing >= assertions
in RegistryComparisonTest (and the similar checks at lines 103-106) will be
stable without test changes.
---
Nitpick comments:
In
`@oshi-common/src/main/java/oshi/driver/common/windows/registry/ProcessPerfCounterBlock.java`:
- Around line 12-13: The class marked `@Immutable`, ProcessPerfCounterBlock,
should be declared final to prevent subclassing from breaking immutability;
update the class declaration to add the final modifier on public class
ProcessPerfCounterBlock (ensure no subclasses rely on extending it and adjust
any tests/usages accordingly) so the intent of the annotation is enforced by the
type system.
- Line 23: The pageFaults field in ProcessPerfCounterBlock is declared as int
but getPageFaults() returns long and native DWORD counters can exceed
Integer.MAX_VALUE; change the pageFaults field to long and update any
constructors/assignments in ProcessPerfCounterBlock to accept a long, then
update call sites in ProcessPerformanceData.buildProcessMapFromRegistry to pass
Integer.toUnsignedLong((Integer) …PAGEFAULTSPERSEC) instead of narrowing to int
and in buildProcessMapFromPerfCounters to stop using
pageFaultsList.get(inst).intValue() (pass the value as a long), ensuring all
types flow as long end-to-end to avoid signed narrowing/wraparound while keeping
the public getter unchanged.
In
`@oshi-core-java25/src/main/java/oshi/driver/windows/registry/HkeyPerformanceDataUtilFFM.java`:
- Around line 302-317: The catch(NumberFormatException) in
mapCounterIndicesFromRegistry is dead since ParseUtil.parseIntOrDefault won't
throw; remove that catch and instead explicitly validate the registry result:
after calling Advapi32UtilFFM.registryGetStringArray (counterText) check for
null and ensure counterText.length > 1, then iterate only up to
counterText.length - 1 (so you never read past the end) and keep the existing
ParseUtil.parseIntOrDefault usage and indexMap.putIfAbsent logic; preserve
returning Collections.unmodifiableMap(indexMap).
🪄 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: c8653283-dd7d-40be-a94e-f0206e373ccb
📒 Files selected for processing (20)
CHANGELOG.mdoshi-benchmark/src/test/java/oshi/comparison/RegistryComparisonTest.javaoshi-common/src/main/java/module-info.javaoshi-common/src/main/java/oshi/driver/common/windows/registry/ProcessPerfCounterBlock.javaoshi-common/src/main/java/oshi/driver/common/windows/registry/ThreadPerfCounterBlock.javaoshi-common/src/main/java/oshi/driver/common/windows/registry/package-info.javaoshi-core-java25/src/main/java/oshi/driver/windows/registry/HkeyPerformanceDataUtilFFM.javaoshi-core-java25/src/main/java/oshi/driver/windows/registry/ProcessPerformanceDataFFM.javaoshi-core-java25/src/main/java/oshi/driver/windows/registry/ThreadPerformanceDataFFM.javaoshi-core-java25/src/main/java/oshi/ffm/windows/WinPerfFFM.javaoshi-core-java25/src/main/java/oshi/ffm/windows/WinRegFFM.javaoshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSProcessFFM.javaoshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOperatingSystemFFM.javaoshi-core/src/main/java/oshi/driver/windows/registry/ProcessPerformanceData.javaoshi-core/src/main/java/oshi/driver/windows/registry/ThreadPerformanceData.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcess.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcessJNA.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOSThread.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOperatingSystem.javaoshi-core/src/test/java/oshi/driver/windows/registry/RegistryDriversTest.java
✅ Files skipped from review due to trivial changes (7)
- oshi-common/src/main/java/module-info.java
- oshi-core-java25/src/main/java/oshi/ffm/windows/WinRegFFM.java
- CHANGELOG.md
- oshi-core/src/main/java/oshi/software/os/windows/WindowsOperatingSystem.java
- oshi-common/src/main/java/oshi/driver/common/windows/registry/package-info.java
- oshi-common/src/main/java/oshi/driver/common/windows/registry/ThreadPerfCounterBlock.java
- oshi-core-java25/src/main/java/oshi/driver/windows/registry/ProcessPerformanceDataFFM.java
🚧 Files skipped from review as they are similar to previous changes (7)
- oshi-core/src/test/java/oshi/driver/windows/registry/RegistryDriversTest.java
- oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOperatingSystemFFM.java
- oshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcessJNA.java
- oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSProcessFFM.java
- oshi-core/src/main/java/oshi/software/os/windows/WindowsOSThread.java
- oshi-core-java25/src/main/java/oshi/driver/windows/registry/ThreadPerformanceDataFFM.java
- oshi-core-java25/src/main/java/oshi/ffm/windows/WinPerfFFM.java
📜 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). (6)
- GitHub Check: Codacy Static Code Analysis
- GitHub Check: Test JDK 25, macos-latest (+ JNA==FFM)
- GitHub Check: Test JDK 25, windows-latest (+ JNA==FFM)
- GitHub Check: Test JDK 21, macos-latest
- GitHub Check: Analyze (java)
- GitHub Check: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)
🧰 Additional context used
🧠 Learnings (11)
📓 Common learnings
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3168
File: oshi-core-java25/src/main/java/oshi/ffm/windows/PdhFFM.java:0-0
Timestamp: 2026-04-17T23:43:33.461Z
Learning: In `oshi-core-java25/src/main/java/oshi/ffm/windows/PdhFFM.java`, the `PDH_RAW_COUNTER_LAYOUT` Java FFM struct layout must place `FirstValue` at byte offset 16 (not 12). The native MSVC compiler inserts 4 bytes of implicit alignment padding before the `LONGLONG FirstValue` field (after CStatus=4 bytes + FILETIME TimeStamp=8 bytes = 12 bytes), because LONGLONG requires 8-byte alignment. The total struct size is 40 bytes (with trailing padding). Do not use JAVA_LONG_UNALIGNED without explicit padding here, as that incorrectly places FirstValue at offset 12 and causes reads of garbage counter values.
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3170
File: oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.java:177-183
Timestamp: 2026-04-18T03:18:03.725Z
Learning: In `oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.java`, GPU engine PDH instance counts (from `GpuInformationJNA.queryGpuEngineCounters()` / `GpuInformationFFM.queryGpuEngineCounters()`) are highly volatile — counts can differ dramatically (e.g., 53 vs 40) even between queries taken milliseconds apart. Do not assert instance count equality or exact instance list matching between JNA and FFM results. The only reliable assertion is that both are empty or both are non-empty (`assertThat(ffm.getA().isEmpty()).isEqualTo(jna.getA().isEmpty())`).
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3014
File: oshi-core-java25/src/main/java/oshi/util/platform/windows/PdhUtilFFM.java:87-89
Timestamp: 2026-03-29T20:03:00.830Z
Learning: In the OSHI FFM codebase (oshi-core-java25), all PDH/Kernel32/COM wrapper methods in classes like PdhFFM, Kernel32FFM, etc. declare `throws Throwable` solely as a compiler artifact of `MethodHandle.invokeExact`. They are native calls and do not throw Java checked exceptions in practice. The enclosing `getOpenFileDescriptors()` method in PdhUtilFFM already has an outer `catch (Throwable t)` that covers the entire method body including any `finally` blocks, so no exception-masking concern exists for cleanup calls like `PdhCloseQuery` in `finally`.
📚 Learning: 2026-04-18T03:18:03.725Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3170
File: oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.java:177-183
Timestamp: 2026-04-18T03:18:03.725Z
Learning: In `oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.java`, GPU engine PDH instance counts (from `GpuInformationJNA.queryGpuEngineCounters()` / `GpuInformationFFM.queryGpuEngineCounters()`) are highly volatile — counts can differ dramatically (e.g., 53 vs 40) even between queries taken milliseconds apart. Do not assert instance count equality or exact instance list matching between JNA and FFM results. The only reliable assertion is that both are empty or both are non-empty (`assertThat(ffm.getA().isEmpty()).isEqualTo(jna.getA().isEmpty())`).
Applied to files:
oshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcess.javaoshi-core/src/main/java/oshi/driver/windows/registry/ProcessPerformanceData.javaoshi-core/src/main/java/oshi/driver/windows/registry/ThreadPerformanceData.javaoshi-benchmark/src/test/java/oshi/comparison/RegistryComparisonTest.javaoshi-core-java25/src/main/java/oshi/driver/windows/registry/HkeyPerformanceDataUtilFFM.java
📚 Learning: 2026-04-17T23:56:43.867Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3168
File: oshi-core-java25/src/main/java/oshi/util/platform/windows/PerfDataUtilFFM.java:287-298
Timestamp: 2026-04-17T23:56:43.867Z
Learning: In `oshi-core-java25/src/main/java/oshi/util/platform/windows/PerfDataUtilFFM.java`, the `queryWildcardCounters` method intentionally aborts and returns an empty Pair when any `addEnglishCounter` call fails. This is by design: the returned `Pair<List<String>, Map<T, List<Long>>>` requires strict parallel alignment between the instance list and each per-property value list. Aborting on failure preserves this alignment contract. This is different from `queryCounters` (non-wildcard), which gracefully skips individual failed counters since it returns a flat `Map<T, Long>` with no alignment constraint.
Applied to files:
oshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcess.javaoshi-core/src/main/java/oshi/driver/windows/registry/ProcessPerformanceData.javaoshi-core/src/main/java/oshi/driver/windows/registry/ThreadPerformanceData.javaoshi-benchmark/src/test/java/oshi/comparison/RegistryComparisonTest.javaoshi-core-java25/src/main/java/oshi/driver/windows/registry/HkeyPerformanceDataUtilFFM.java
📚 Learning: 2026-04-17T23:52:52.926Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3168
File: oshi-common/src/main/java/oshi/driver/common/windows/perfmon/LoadAverage.java:47-58
Timestamp: 2026-04-17T23:52:52.926Z
Learning: In `oshi-common/src/main/java/oshi/driver/common/windows/perfmon/LoadAverage.java`, the `stopDaemon()` / `startDaemon()` lifecycle pattern (both `public synchronized` instance methods on the same monitor) is intentionally safe: `stopDaemon()` sets `loadAvgThread = null` immediately after `interrupt()`, and `startDaemon()` checks `loadAvgThread != null` under the same lock. Since both methods are synchronized on `this`, they cannot run concurrently, so no double-sampler race is possible. Do not flag this pattern as a race condition.
Applied to files:
oshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcess.javaoshi-core/src/main/java/oshi/driver/windows/registry/ProcessPerformanceData.javaoshi-core/src/main/java/oshi/driver/windows/registry/ThreadPerformanceData.java
📚 Learning: 2026-03-29T20:03:00.830Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3014
File: oshi-core-java25/src/main/java/oshi/util/platform/windows/PdhUtilFFM.java:87-89
Timestamp: 2026-03-29T20:03:00.830Z
Learning: In the OSHI FFM codebase (oshi-core-java25), all PDH/Kernel32/COM wrapper methods in classes like PdhFFM, Kernel32FFM, etc. declare `throws Throwable` solely as a compiler artifact of `MethodHandle.invokeExact`. They are native calls and do not throw Java checked exceptions in practice. The enclosing `getOpenFileDescriptors()` method in PdhUtilFFM already has an outer `catch (Throwable t)` that covers the entire method body including any `finally` blocks, so no exception-masking concern exists for cleanup calls like `PdhCloseQuery` in `finally`.
Applied to files:
oshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcess.javaoshi-core/src/main/java/oshi/driver/windows/registry/ThreadPerformanceData.javaoshi-core-java25/src/main/java/oshi/driver/windows/registry/HkeyPerformanceDataUtilFFM.java
📚 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, only interfaces and classes in the root packages `oshi`, `oshi.hardware`, and `oshi.software.os` are considered the public API. Code in subpackages that represent specific implementations/platforms (e.g., `oshi.software.os.linux`, `oshi.hardware.platform.linux`, and similar subpackages) is implementation detail. When reviewing, do not treat changes to classes in these platform-specific subpackages as public API breaks (for example: making `LinuxOperatingSystem` abstract, narrowing constructor visibility, or adding/removing abstract methods should not be flagged as breaking public API).
Applied to files:
oshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcess.java
📚 Learning: 2026-04-17T23:43:33.461Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3168
File: oshi-core-java25/src/main/java/oshi/ffm/windows/PdhFFM.java:0-0
Timestamp: 2026-04-17T23:43:33.461Z
Learning: In `oshi-core-java25/src/main/java/oshi/ffm/windows/PdhFFM.java`, the `PDH_RAW_COUNTER_LAYOUT` Java FFM struct layout must place `FirstValue` at byte offset 16 (not 12). The native MSVC compiler inserts 4 bytes of implicit alignment padding before the `LONGLONG FirstValue` field (after CStatus=4 bytes + FILETIME TimeStamp=8 bytes = 12 bytes), because LONGLONG requires 8-byte alignment. The total struct size is 40 bytes (with trailing padding). Do not use JAVA_LONG_UNALIGNED without explicit padding here, as that incorrectly places FirstValue at offset 12 and causes reads of garbage counter values.
Applied to files:
oshi-common/src/main/java/oshi/driver/common/windows/registry/ProcessPerfCounterBlock.javaoshi-core/src/main/java/oshi/driver/windows/registry/ProcessPerformanceData.javaoshi-core/src/main/java/oshi/driver/windows/registry/ThreadPerformanceData.javaoshi-benchmark/src/test/java/oshi/comparison/RegistryComparisonTest.javaoshi-core-java25/src/main/java/oshi/driver/windows/registry/HkeyPerformanceDataUtilFFM.java
📚 Learning: 2026-04-12T19:22:09.716Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3149
File: oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacCentralProcessor.java:159-163
Timestamp: 2026-04-12T19:22:09.716Z
Learning: When reviewing OSHI hardware platform code that uses or implements `CentralProcessor`/`PhysicalProcessor.getEfficiency()`, remember the API’s counterintuitive semantics: a *higher* efficiency-class value indicates *greater performance* (lower efficiency). P-cores/“performance cores” should therefore have higher values (e.g., 1) than E-cores/“efficiency cores” (e.g., 0), as documented in the `CentralProcessor` Javadoc. Do not flag code as incorrect solely because ARM_P_CORES or Intel P-cores are assigned higher efficiency values.
Applied to files:
oshi-common/src/main/java/oshi/driver/common/windows/registry/ProcessPerfCounterBlock.java
📚 Learning: 2026-04-15T04:56:18.352Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3163
File: oshi-core-java25/src/test/java/oshi/ffm/mac/CoreFoundationTest.java:97-103
Timestamp: 2026-04-15T04:56:18.352Z
Learning: In CoreFoundationTest.java (oshi-core-java25/src/test/java/oshi/ffm/mac/CoreFoundationTest.java), asserting exact CFGetRetainCount deltas (+1 after retain, -1 after release) is intentional and considered reliable for freshly created CF objects (e.g., CFStringRef via CFStringRef.createCFString) where the test holds sole ownership. Do not flag these assertions as flaky — the Apple "avoid CFGetRetainCount" advisory applies to shared/framework-managed objects, not exclusively owned objects in unit tests.
Applied to files:
oshi-benchmark/src/test/java/oshi/comparison/RegistryComparisonTest.java
📚 Learning: 2026-04-10T22:44:36.786Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3136
File: oshi-core-java25/src/main/java/oshi/software/os/linux/LinuxOperatingSystemFFM.java:46-53
Timestamp: 2026-04-10T22:44:36.786Z
Learning: In OSHI's `AuxvFFM.queryAuxv()` (oshi-core-java25/src/main/java/oshi/driver/linux/proc/AuxvFFM.java), the do-while loop is safe even when `/proc/self/auxv` cannot be read: `FileUtil.readAllBytesAsBuffer` returns an empty ByteBuffer on failure, and `FileUtil.readLongFromBuffer`/`readIntFromBuffer` return 0L when reading past the buffer limit. This 0L equals AT_NULL, causing the loop to exit immediately with an empty map, which triggers the `getconf`/hardcoded-default fallback in callers like `LinuxOperatingSystemFFM`. Do not flag this do-while loop or the static initializer that calls `AuxvFFM.queryAuxv()` as unsafe.
Applied to files:
oshi-core-java25/src/main/java/oshi/driver/windows/registry/HkeyPerformanceDataUtilFFM.java
📚 Learning: 2026-04-03T02:07:47.621Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3110
File: oshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacHWDiskStoreFFM.java:119-121
Timestamp: 2026-04-03T02:07:47.621Z
Learning: In OSHI’s Java FFM/API implementation classes (e.g., *FFM.java) that implement/override `updateAttributes()`, preserve the intentional failure-handling pattern: catch `Throwable` and return `false` without logging. `updateAttributes()` is a public API whose contract is to signal failure via the boolean return value, and callers rely on that return value (so emitting logs from this path is not desired and should not be introduced during review unless the method contract changes).
Applied to files:
oshi-core-java25/src/main/java/oshi/driver/windows/registry/HkeyPerformanceDataUtilFFM.java
🔇 Additional comments (6)
oshi-core/src/main/java/oshi/driver/windows/registry/ThreadPerformanceData.java (1)
17-17: LGTM — mechanical swap to sharedThreadPerfCounterBlockPOJO.Return-type changes and the two
new ThreadPerfCounterBlock(...)call sites match the 11-arg constructor order, Javadoc@returntags were updated, and the removed inner class is no longer referenced.Also applies to: 42-85, 95-159
oshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcess.java (1)
23-24: LGTM — consumer updated to the shared POJO types.Constructor, field, and method signatures correctly thread
Map<Integer, ProcessPerfCounterBlock>/Map<Integer, ThreadPerfCounterBlock>through, andgetThreadDetails()/updateAttributes(pcb, wts)read the expected getters from the new POJOs.Also applies to: 61-89, 262-286, 296-336, 365-371
oshi-core/src/main/java/oshi/driver/windows/registry/ProcessPerformanceData.java (1)
16-16: LGTM — builders now return the sharedProcessPerfCounterBlockmap.Both
buildProcessMapFromRegistryandbuildProcessMapFromPerfCountersconstructor calls match the new 10-arg POJO signature (name, parentProcessID, priority, privateWorkingSetSize, workingSetSize, startTime, upTime, bytesRead, bytesWritten, pageFaults). The pre-existing conversion logic for the 1601 vs 1970 epoch is preserved.Also applies to: 41-83, 92-94, 104-144
oshi-benchmark/src/test/java/oshi/comparison/RegistryComparisonTest.java (1)
27-135: LGTM — tolerances and overlap thresholds look sound.Zero-branch in
assertWithinRationow compares against an absolute byte tolerance; 90% overlap uses the correct ceiling formula; threadstartTimebound is justified by the documented 1/64s tick resolution plus rounding. With thepageFaults/contextSwitcheswidening handled at the POJO level, the cumulative>=checks should be stable.oshi-core-java25/src/main/java/oshi/driver/windows/registry/HkeyPerformanceDataUtilFFM.java (2)
252-288: LGTM — synchronized buffer growth with properretvalidation.Serializing
HKEY_PERFORMANCE_DATAaccess viasynchronizedmatches Windows guidance, the post-loopret != ERROR_SUCCESScheck (addressed earlier) closes the garbage-buffer hole, andArena.ofAuto()is appropriate here because the returnedMemorySegment's lifetime is managed via GC reachability from the caller.
85-208: LGTM — PERF_DATA_BLOCK walk is correct and fail-safe.Object iteration correctly advances by
TotalByteLength, counter definitions byByteLength, and instance blocks byperfCounterBlockOffset + PERF_COUNTER_BLOCK_ByteLength. Unknown counter sizes or missing enum indices fall through toreturn null, which is the documented contract for partial failure.
| assertThat(p.getBytesRead()).as("process[%d].bytesRead", pid).isGreaterThanOrEqualTo(r.getBytesRead()); | ||
| assertThat(p.getBytesWritten()).as("process[%d].bytesWritten", pid) | ||
| .isGreaterThanOrEqualTo(r.getBytesWritten()); | ||
| assertThat(p.getPageFaults()).as("process[%d].pageFaults", pid).isGreaterThanOrEqualTo(r.getPageFaults()); |
There was a problem hiding this comment.
Cumulative-counter >= assertions are coupled to the signed-int wrap of pageFaults / contextSwitches.
getPageFaults() in ProcessPerfCounterBlock and getContextSwitches() in ThreadPerfCounterBlock both widen an int field to long in their getters. On a process/thread where the raw native counter crosses Integer.MAX_VALUE, one side can observe the wrapped (negative) value while the other sees a different wrap point, making the isGreaterThanOrEqualTo(r.getPageFaults()) / isGreaterThanOrEqualTo(r.getContextSwitches()) checks flaky on long-running machines. The root fix is to store these counters as long in the POJOs (see comment on ProcessPerfCounterBlock.pageFaults); once that is done, these assertions become robust with no test-side change required.
Also applies to: 103-106
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@oshi-benchmark/src/test/java/oshi/comparison/RegistryComparisonTest.java`
around lines 60 - 63, The assertions fail when native cumulative counters wrap
because ProcessPerfCounterBlock.pageFaults and
ThreadPerfCounterBlock.contextSwitches are stored as int and only widened in
getters; change those POJO fields to long, update their getters
(getPageFaults(), getContextSwitches()) to return long, and adjust any
constructors/assignment sites that set those fields to use long values so the
stored value never loses precision; after this change the existing >= assertions
in RegistryComparisonTest (and the similar checks at lines 103-106) will be
stable without test changes.
Parse HKEY_PERFORMANCE_DATA binary structs via FFM for process and thread performance data, bypassing the PDH abstraction layer. New in oshi-common: - ProcessPerfCounterBlock and ThreadPerfCounterBlock POJOs extracted from oshi-core inner classes to avoid FFM->JNA dependency New in oshi-core-java25: - WinPerfFFM: FFM struct layouts for PERF_DATA_BLOCK, PERF_OBJECT_TYPE, PERF_COUNTER_DEFINITION, PERF_INSTANCE_DEFINITION, PERF_COUNTER_BLOCK - HkeyPerformanceDataUtilFFM: Core HKEY_PERFORMANCE_DATA binary parser - ProcessPerformanceDataFFM and ThreadPerformanceDataFFM: Registry-based process/thread data drivers - WinRegFFM: Added HKEY_PERFORMANCE_DATA constant Updated oshi-core and oshi-benchmark to use common POJOs. New RegistryComparisonTest in oshi-benchmark validates JNA vs FFM registry parsing produces matching results.
575c0f2 to
bdb3119
Compare
Summary
Parse HKEY_PERFORMANCE_DATA binary structs via FFM for process and thread performance data, bypassing the PDH abstraction layer for faster access.
Changes
oshi-common
ProcessPerfCounterBlockandThreadPerfCounterBlockPOJOs from oshi-core inner classes intooshi.driver.common.windows.registrypackage, enabling FFM code to use them without depending on oshi-core (JNA)exports oshi.driver.common.windows.registryto module-infooshi-core-java25
WinPerfFFM: FFM struct layouts forPERF_DATA_BLOCK,PERF_OBJECT_TYPE,PERF_COUNTER_DEFINITION,PERF_INSTANCE_DEFINITION,PERF_COUNTER_BLOCKwith pre-computed field offset constantsHkeyPerformanceDataUtilFFM: Core parser for HKEY_PERFORMANCE_DATA binary data using FFMRegQueryValueExProcessPerformanceDataFFMandThreadPerformanceDataFFM: Registry-based process/thread data driversWinRegFFM: AddHKEY_PERFORMANCE_DATAconstantWindowsOperatingSystemFFM: Switch from JNA to FFM registry data classesoshi-core
PerfCounterBlockclasses fromProcessPerformanceDataandThreadPerformanceData, replaced by common POJOsWindowsOperatingSystem,WindowsOSProcess,WindowsOSProcessJNA,WindowsOSThreadoshi-benchmark
RegistryComparisonTest: Validates JNA vs FFM registry parsing produces matching results (exact match on static fields, tolerance on dynamic/timing-sensitive fields)Testing
mvn clean spotless:apply install checkstyle:check,forbiddenapis:check,javadoc:aggregateSummary by CodeRabbit
New Features
Tests
Refactor
Chores