Repository navigation
Fix Solaris kstat2 for non-zero CPU instances, cap FileSystemTest - #3326
Conversation
- [SPARC-DEBUG] warn logging in SolarisCentralProcessor for kstat chain - [TIMING] warn logging in SystemInfoTest for each phase - [TIMING] warn logging in FileSystemTest for getFileStores and iteration - Dedicated solaris-debug.yaml workflow with kstat/df diagnostics
- queryKstat2List: handle non-zero-based and gapped kstat instances (tolerates up to 256 consecutive misses before stopping) - queryProcessorId2: use queryKstat2List instead of hardcoding cpu/0 - HAS_KSTAT2: validate with runtime probe using universal kstat path - FileSystemTest: cap updateAttributes() to first 10 stores (avoids 22-minute hang on systems with many NFS mounts) - ProcessStatTest: fix flaky testQuerySocketToPidMap in containers - unix.yaml: re-enable full test suite on cfarm216
📝 WalkthroughWalkthroughThis PR improves Solaris kstat2 handling robustness and makes tests more resilient to constrained environments. The main functional change enhances kstat2 availability detection, bounds list iteration to prevent infinite loops, and updates processor queries to use the safer approach. Supporting changes expand CI test coverage and relax test assertions for restricted systems. ChangesSolaris Kstat2 Availability Detection and Bounded Query Strategy
Test and CI Environment Resilience
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3326 +/- ##
============================================
- Coverage 75.01% 74.89% -0.12%
Complexity 76 76
============================================
Files 455 455
Lines 17492 17492
Branches 2872 2872
============================================
- Hits 13121 13101 -20
- Misses 2780 2791 +11
- Partials 1591 1600 +9
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
oshi-core/src/main/java/oshi/util/platform/unix/solaris/KstatUtil.java (1)
294-330:⚠️ Potential issue | 🟠 Major | 🏗️ Heavy liftPreserve the matched kstat instance instead of only the values.
This scan can now find sparse/non-zero CPU maps, but
queryKstat2List()still drops the instance number and forces callers to treat list position as CPU id. That breaks the cross-file contract inSolarisCentralProcessor:initProcessorCounts2()assignsprocId = logProcs.size()whilemapNumaNodes()is keyed by real CPU ids fromlgrpinfo(Lines 145-157 and 160-180), and the frequency/tick paths also fill arrays by ordinal (Lines 217-229 and 311-324). On the exact systems this PR targets, you'll still misattribute per-CPU metadata even when lookup succeeds. Return(instance, values)or a map keyed by instance, and let callers build/logically order processors from the real ids rather than row order.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@oshi-core/src/main/java/oshi/util/platform/unix/solaris/KstatUtil.java` around lines 294 - 330, queryKstat2List currently discards the kstat instance number and returns only values (List<Object[]>), causing callers like SolarisCentralProcessor to misattribute per-CPU metadata; change queryKstat2List to preserve the numeric instance from the lookup key and return either a Map<Integer,Object[]> keyed by instance or a List of (instance, values) tuples so callers can order by real CPU id, i.e., when you call handle.lookupMap(beforeStr + s + afterStr) capture s (the instance) and store it with the result instead of only adding result to results; update callers (e.g., initProcessorCounts2, mapNumaNodes and frequency/tick paths) to consume the instance-keyed results and build processor arrays in real-id order.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@oshi-core/src/main/java/oshi/util/platform/unix/solaris/KstatUtil.java`:
- Around line 294-330: queryKstat2List currently discards the kstat instance
number and returns only values (List<Object[]>), causing callers like
SolarisCentralProcessor to misattribute per-CPU metadata; change queryKstat2List
to preserve the numeric instance from the lookup key and return either a
Map<Integer,Object[]> keyed by instance or a List of (instance, values) tuples
so callers can order by real CPU id, i.e., when you call
handle.lookupMap(beforeStr + s + afterStr) capture s (the instance) and store it
with the result instead of only adding result to results; update callers (e.g.,
initProcessorCounts2, mapNumaNodes and frequency/tick paths) to consume the
instance-keyed results and build processor arrays in real-id order.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 99ce5459-f5fc-470a-888d-c1402d597142
📒 Files selected for processing (6)
.github/workflows/unix.yamloshi-common/src/test/java/oshi/util/driver/linux/proc/ProcessStatTest.javaoshi-core/src/main/java/oshi/hardware/platform/unix/solaris/SolarisCentralProcessor.javaoshi-core/src/main/java/oshi/software/os/unix/solaris/SolarisOperatingSystem.javaoshi-core/src/main/java/oshi/util/platform/unix/solaris/KstatUtil.javaoshi-core/src/test/java/oshi/software/os/shared/FileSystemTest.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). (13)
- 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 21, macos-latest
- GitHub Check: Test JDK 26, macos-latest
- GitHub Check: Test JDK 25, macos-latest (+ JNA==FFM)
- GitHub Check: Test JDK 26, windows-latest
- GitHub Check: JMH Benchmarks, windows-latest
- GitHub Check: JMH Benchmarks, macos-latest
- GitHub Check: JMH Benchmarks, ubuntu-latest
- GitHub Check: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)
- GitHub Check: Test JDK 25, FreeBSD (+ JNA==FFM)
- GitHub Check: Analyze (java)
🧰 Additional context used
🧠 Learnings (15)
📓 Common learnings
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3307
File: .github/workflows/netbsd.yaml:4-8
Timestamp: 2026-05-30T02:27:59.447Z
Learning: In the oshi/oshi repository, the `.github/workflows/netbsd.yaml` CI workflow intentionally triggers only on `push` to the `netbsd-port` branch during development. Before the final merge to master, NetBSD CI will be integrated into the main Unix CI workflow (e.g., `.github/workflows/pr.yaml` or equivalent). Do not flag the limited trigger scope as an issue on this PR.
📚 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-common/src/test/java/oshi/util/driver/linux/proc/ProcessStatTest.javaoshi-core/src/main/java/oshi/software/os/unix/solaris/SolarisOperatingSystem.java
📚 Learning: 2026-05-18T23:38:59.650Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3267
File: oshi-common/src/main/java/oshi/driver/common/windows/wmi/Win32Process.java:89-100
Timestamp: 2026-05-18T23:38:59.650Z
Learning: In `oshi-common/src/main/java/oshi/driver/common/windows/wmi/Win32Process.java`, the `queryProcesses(WmiQueryExecutor h, Collection<Integer> pids)` method intentionally uses `Collection<Integer>` (not `Set<Integer>`) to match the JNA original and to remain flexible for callers passing `List` or other collection types. The `queryCommandLines` method uses `Set<Integer>` only because its callers happen to pass sets. Do not suggest narrowing `queryProcesses` to `Set<Integer>`.
Applied to files:
oshi-common/src/test/java/oshi/util/driver/linux/proc/ProcessStatTest.java
📚 Learning: 2026-04-18T03:18:06.205Z
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:06.205Z
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-common/src/test/java/oshi/util/driver/linux/proc/ProcessStatTest.javaoshi-core/src/test/java/oshi/software/os/shared/FileSystemTest.java
📚 Learning: 2026-04-03T02:07:49.467Z
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:49.467Z
Learning: In `oshi-core-java25/src/main/java/oshi/hardware/platform/mac/MacHWDiskStoreFFM.java` (and similar FFM/API implementations in OSHI), the `updateAttributes()` method intentionally uses `catch (Throwable e) { return false; }` without logging. This is by design: `updateAttributes()` is a public API method whose contract is to return `false` on failure; callers consume the boolean and would never see log output, so adding a log statement is not desired.
Applied to files:
oshi-core/src/test/java/oshi/software/os/shared/FileSystemTest.java
📚 Learning: 2026-05-30T02:27:59.447Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3307
File: .github/workflows/netbsd.yaml:4-8
Timestamp: 2026-05-30T02:27:59.447Z
Learning: In the oshi/oshi repository, the `.github/workflows/netbsd.yaml` CI workflow intentionally triggers only on `push` to the `netbsd-port` branch during development. Before the final merge to master, NetBSD CI will be integrated into the main Unix CI workflow (e.g., `.github/workflows/pr.yaml` or equivalent). Do not flag the limited trigger scope as an issue on this PR.
Applied to files:
.github/workflows/unix.yaml
📚 Learning: 2026-05-31T05:53:04.246Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3311
File: .github/workflows/site.yaml:21-21
Timestamp: 2026-05-31T05:53:04.246Z
Learning: When a GitHub Actions workflow verifies that a pinned commit SHA matches a version tag, dereference annotated tags before comparing to a commit SHA. The API `GET /repos/{owner}/{repo}/git/refs/tags/{tag}` returns the tag *object* SHA for annotated tags (not the underlying commit SHA), so comparing it directly to a commit SHA will cause false mismatches. Instead: (1) fetch the tag object SHA via `GET /repos/{owner}/{repo}/git/refs/tags/{tag}`; (2) resolve that tag object to the underlying commit by calling `GET /repos/{owner}/{repo}/git/tags/{tag_object_sha}`; (3) compare the pinned commit SHA to the resolved commit at `.object.sha`.
Applied to files:
.github/workflows/unix.yaml
📚 Learning: 2026-03-29T20:01:06.452Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3014
File: oshi-core-java11/src/main/java/module-info.java:10-17
Timestamp: 2026-03-29T20:01:06.452Z
Learning: In the oshi project, `oshi-core-java25/src/main/java/module-info.java` intentionally does NOT export `oshi.util.platform.unix.freebsd`, `oshi.util.platform.unix.openbsd`, or `oshi.util.platform.unix.solaris`, because the FFM (Foreign Function & Memory) implementation only supports Windows, macOS, and Linux. This differs from `oshi-core-java11/src/main/java/module-info.java` which exports all Unix platform packages. The asymmetry is by design.
Applied to files:
oshi-core/src/main/java/oshi/software/os/unix/solaris/SolarisOperatingSystem.javaoshi-core/src/main/java/oshi/hardware/platform/unix/solaris/SolarisCentralProcessor.javaoshi-core/src/main/java/oshi/util/platform/unix/solaris/KstatUtil.java
📚 Learning: 2026-05-04T04:58:36.843Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3227
File: oshi-metrics/src/main/java/oshi/metrics/OshiMetrics.java:35-48
Timestamp: 2026-05-04T04:58:36.843Z
Learning: In `oshi-metrics/src/main/java/oshi/metrics/OshiMetrics.java`, the `private final OperatingSystem os` field is intentionally stored in the constructor even though it is not yet used. It is a placeholder for future OS-level metrics (e.g., process metrics) that will be added incrementally. Do not flag it as dead code.
Applied to files:
oshi-core/src/main/java/oshi/software/os/unix/solaris/SolarisOperatingSystem.javaoshi-core/src/main/java/oshi/hardware/platform/unix/solaris/SolarisCentralProcessor.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/unix/solaris/SolarisOperatingSystem.javaoshi-core/src/main/java/oshi/hardware/platform/unix/solaris/SolarisCentralProcessor.java
📚 Learning: 2026-05-31T04:49:16.646Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3310
File: oshi-core/src/main/java/oshi/software/os/unix/netbsd/NetBsdOperatingSystem.java:164-166
Timestamp: 2026-05-31T04:49:16.646Z
Learning: In the oshi/oshi project, the NetBSD platform intentionally removes all JNA/native library dependencies (PR `#3310`). `NetBsdOperatingSystem.getThreadId()` uses `(int) Thread.currentThread().getId()` rather than `NetBsdLibc._lwp_self()` because the JNA native library is not bundled with the Maven dependency for the NetBSD platform. The mismatch between Java thread ids and kernel LWP ids is an accepted trade-off. Do not suggest reintroducing JNA-based calls (such as `NetBsdLibc._lwp_self()`) in NetBSD platform code.
Applied to files:
oshi-core/src/main/java/oshi/hardware/platform/unix/solaris/SolarisCentralProcessor.javaoshi-core/src/main/java/oshi/util/platform/unix/solaris/KstatUtil.java
📚 Learning: 2026-04-03T18:44:48.200Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3112
File: oshi-core/src/main/java/oshi/PlatformEnum.java:63-66
Timestamp: 2026-04-03T18:44:48.200Z
Learning: In oshi/oshi PlatformEnum.java, the DRAGONFLYBSD enum constant is intentionally added for platform detection only (no implementation classes exist yet). It allows UnsupportedOperationException messages to say "DragonFly BSD" rather than "Unknown". Full DragonFly BSD support is tracked in issue `#2583`. Do not flag the missing switch-case implementations as a bug.
Applied to files:
oshi-core/src/main/java/oshi/hardware/platform/unix/solaris/SolarisCentralProcessor.javaoshi-core/src/main/java/oshi/util/platform/unix/solaris/KstatUtil.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-core/src/main/java/oshi/util/platform/unix/solaris/KstatUtil.java
📚 Learning: 2026-04-03T18:43:51.290Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3112
File: oshi-core/src/main/java/oshi/PlatformEnum.java:99-100
Timestamp: 2026-04-03T18:43:51.290Z
Learning: In oshi/oshi PlatformEnum.java, the DragonFly BSD detection uses `osName.equalsIgnoreCase("dragonflybsd")` intentionally, mirroring the exact same check in JNA's `Platform.java` source. Java's `os.name` property on DragonFly BSD is "dragonflybsd" (no space), so `startsWith("DragonFly")` is NOT the correct pattern here. Do not suggest changing it to `startsWith`.
Applied to files:
oshi-core/src/main/java/oshi/util/platform/unix/solaris/KstatUtil.java
📚 Learning: 2026-04-17T23:56:46.416Z
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:46.416Z
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/util/platform/unix/solaris/KstatUtil.java
🔇 Additional comments (6)
.github/workflows/unix.yaml (1)
105-105: LGTM!oshi-common/src/test/java/oshi/util/driver/linux/proc/ProcessStatTest.java (2)
10-11: LGTM!
97-98: LGTM!oshi-core/src/test/java/oshi/software/os/shared/FileSystemTest.java (3)
12-12: LGTM!
41-43: LGTM!
71-81: LGTM!
Fixes discovered while debugging cfarm216 (Solaris 11.4 SPARC LDOM with CPUs starting at instance 64):
Solaris kstat2 fixes:
queryKstat2List: handle non-zero-based and gapped kstat instances (tolerates up to 256 consecutive misses before stopping iteration)queryProcessorId2: usequeryKstat2Listinstead of hardcodingcpu/0pathHAS_KSTAT2: validate with runtime probe using universalkstat:/pages/unix/system_pagespathTest fixes:
FileSystemTest: capupdateAttributes()to first 10 stores (avoids 22-minute hang on systems with many NFS mounts)ProcessStatTest: fix flakytestQuerySocketToPidMapin containers where no sockets may be visibleCI:
Summary by CodeRabbit
Bug Fixes
Tests