Skip to content

Extract AixOperatingSystem base and shared perfstat process carrier - #3469

Merged
dbwiddis merged 1 commit into
oshi:masterfrom
dbwiddis:aix-os-dedup
Jul 17, 2026
Merged

dbwiddis merged 1 commit into
oshi:masterfrom
dbwiddis:aix-os-dedup

Conversation

@dbwiddis

@dbwiddis dbwiddis commented Jul 17, 2026 •

Copy link
Copy Markdown
Member

Part of the cross-OS consistency/dedup audit (OperatingSystem subsystem — AIX). AIX was the largest remaining single duplication hotspot: it is the only platform whose OperatingSystem JNA and FFM twins extend AbstractOperatingSystem directly, with no common base, so they duplicated ~200 lines.

Shared perfstat carrier

New oshi.driver.common.unix.aix.AixPerfstatProcess (oshi-common) — a backend-neutral POJO holding the perfstat_process_t fields OSHI consumes. PerfstatProcessJNA now maps its JNA Structure array into this carrier, and PerfstatProcessFFM returns it in place of its own private ProcessInfo POJO. Both drivers therefore hand back the same type.

AixOperatingSystem base

New abstract AixOperatingSystem (oshi-common) holds all the shared logic — getServices, version/manufacturer, boot time, installed applications, and the perfstat-driven queryAllProcesses/getProcess/getProcessCount/getThreadCount/getCurrentThread (operating on the carrier). The JNA and FFM twins collapse from ~254/253 lines to ~72/78, providing only hooks:

  • queryPerfstatProcesses() — the perfstat array (via the driver),
  • queryOsBuildRaw() / is64BitKernel() — the partition-config reads,
  • createProcess(...) — the OSProcess factory,
  • plus the native getProcessId/getThreadId and the InternetProtocolStats/NetworkParams factories.

The partition-config POJO is intentionally not promoted to a shared carrier — its other fields feed AixCentralProcessor/AixGlobalMemory, out of scope here — so config access stays as the two small hooks above.

AixOSProcess

With the carrier in place, AixOSProcess's duplicated procCpu iteration (updateAttributes) and its getrlimit-based open-file-limit skeleton move into the base (behind an AixPerfstatProcess[] supplier and a queryRlimitNofile(boolean) hook, matching the BsdOSProcess pattern). The twins keep only the native getrlimit, the affinity supplier, and the queryArgsEnv address-space read.

No CHANGELOG entry: behavior is identical.

Local gate: spotless, checkstyle (the carrier is added to the existing AIX perfstat-POJO suppression), forbiddenapis, javadoc, and a clean full-reactor build all pass; oshi-common and oshi-core tests pass (PerfstatJNATest updated for the new return type). AIX runtime, including JNA==FFM parity, is validated on the compile farm (dispatched separately, since cfarm does not run on pull requests).

Summary by CodeRabbit

  • New Features
    • Improved AIX process monitoring with more consistent CPU, memory, and thread metrics across supported native access methods.
    • Enhanced AIX process handling to provide uniform behavior for CPU/memory reporting and open-file limit reporting.
  • Bug Fixes
    • Processes that can’t be found in perfstat data are now correctly marked invalid.
  • Tests
    • Updated AIX perfstat process query tests to validate against the shared AIX process representation.

@coderabbitai

coderabbitai Bot commented Jul 17, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: cda77f18-5108-4dcd-8c89-b2d8be347029

📥 Commits

Reviewing files that changed from the base of the PR and between 7ec51db and e9f90a0.

📒 Files selected for processing (11)
  • config/checkstyle-suppressions.xml
  • oshi-common/src/main/java/oshi/driver/common/unix/aix/AixPerfstatProcess.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/aix/AixOSProcess.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/aix/AixOperatingSystem.java
  • oshi-core-ffm/src/main/java/oshi/driver/unix/aix/perfstat/PerfstatProcessFFM.java
  • oshi-core-ffm/src/main/java/oshi/software/os/unix/aix/AixOSProcessFFM.java
  • oshi-core-ffm/src/main/java/oshi/software/os/unix/aix/AixOperatingSystemFFM.java
  • oshi-core/src/main/java/oshi/driver/unix/aix/perfstat/PerfstatProcessJNA.java
  • oshi-core/src/main/java/oshi/software/os/unix/aix/AixOSProcessJNA.java
  • oshi-core/src/main/java/oshi/software/os/unix/aix/AixOperatingSystemJNA.java
  • oshi-core/src/test/java/oshi/driver/unix/aix/perfstat/PerfstatJNATest.java
🚧 Files skipped from review as they are similar to previous changes (10)
  • oshi-common/src/main/java/oshi/driver/common/unix/aix/AixPerfstatProcess.java
  • oshi-core/src/test/java/oshi/driver/unix/aix/perfstat/PerfstatJNATest.java
  • config/checkstyle-suppressions.xml
  • oshi-core-ffm/src/main/java/oshi/software/os/unix/aix/AixOSProcessFFM.java
  • oshi-core/src/main/java/oshi/software/os/unix/aix/AixOperatingSystemJNA.java
  • oshi-core/src/main/java/oshi/software/os/unix/aix/AixOSProcessJNA.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/aix/AixOSProcess.java
  • oshi-core-ffm/src/main/java/oshi/driver/unix/aix/perfstat/PerfstatProcessFFM.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/aix/AixOperatingSystem.java
  • oshi-core-ffm/src/main/java/oshi/software/os/unix/aix/AixOperatingSystemFFM.java
📜 Recent review details
⏰ Context from checks skipped due to timeout. (12)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Test JDK 25, macos-latest (+ JNA==FFM)
  • GitHub Check: Test JDK 21, windows-latest
  • GitHub Check: Test JDK 26, windows-latest
  • GitHub Check: Test JDK 21, macos-latest
  • GitHub Check: Test JDK 26, macos-latest
  • GitHub Check: Test JDK 25, windows-latest (+ JNA==FFM)
  • GitHub Check: Test JDK 25, FreeBSD (+ JNA==FFM)
  • GitHub Check: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)
  • GitHub Check: Test JDK 25, OpenBSD (+ JNA==FFM)
  • GitHub Check: Test JDK 25, OpenIndiana (+ JNA==FFM)
  • GitHub Check: Analyze (java)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2026-07-06T19:25:59.225Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3432
File: oshi-common/src/main/java/oshi/util/ExceptionUtil.java:26-56
Timestamp: 2026-07-06T19:25:59.225Z
Learning: In this repo’s SLF4J 1.x-compatible logging code, do not flag cases where a logger call uses SLF4J 1.6+ implicit-cause handling—e.g., `log.error("...{}", value, t)` (or similar with a single `{}` placeholder) where `t` is passed as the final/trailing argument. SLF4J will attach `t` as the log event’s cause with the full stack trace; this is equivalent to SLF4J 2.x’s fluent `atLevel(...).setCause(t).log(...)` and is intentionally used to preserve SLF4J 1.x runtime compatibility.

Applied to files:

  • oshi-core/src/main/java/oshi/driver/unix/aix/perfstat/PerfstatProcessJNA.java
🔇 Additional comments (1)
oshi-core/src/main/java/oshi/driver/unix/aix/perfstat/PerfstatProcessJNA.java (1)

7-12: LGTM!

Also applies to: 38-38, 48-64


📝 Walkthrough

Walkthrough

Changes

The AIX implementation now shares a common perfstat process data carrier and abstract operating-system layer. JNA and FFM backends provide platform-specific hooks, while common process, service, timing, application, and rlimit behavior is centralized.

AIX OS abstraction

Layer / File(s) Summary
Shared perfstat process contract
oshi-common/.../AixPerfstatProcess.java, oshi-core/.../PerfstatProcessJNA.java, oshi-core-ffm/.../PerfstatProcessFFM.java, oshi-core/src/test/.../PerfstatJNATest.java, config/checkstyle-suppressions.xml
Perfstat drivers and tests use AixPerfstatProcess for mapped process data instead of backend-specific types.
Common AIX OS and process behavior
oshi-common/.../AixOperatingSystem.java, oshi-common/.../AixOSProcess.java
Shared AIX process enumeration, lifecycle updates, system queries, services, applications, and open-file-limit contracts are implemented in common classes.
JNA and FFM backend integration
oshi-core/.../aix/*JNA.java, oshi-core-ffm/.../aix/*FFM.java
JNA and FFM subclasses provide perfstat, kernel, process-construction, network, and native rlimit implementations through the common abstractions.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant AixOperatingSystemJNA
  participant AixOperatingSystemFFM
  participant AixOperatingSystem
  participant PerfstatProcessJNA
  participant PerfstatProcessFFM
  participant AixOSProcess
  AixOperatingSystemJNA->>AixOperatingSystem: provide JNA platform hooks
  AixOperatingSystemFFM->>AixOperatingSystem: provide FFM platform hooks
  AixOperatingSystem->>PerfstatProcessJNA: query JNA process records
  AixOperatingSystem->>PerfstatProcessFFM: query FFM process records
  PerfstatProcessJNA-->>AixOperatingSystem: AixPerfstatProcess[]
  PerfstatProcessFFM-->>AixOperatingSystem: AixPerfstatProcess[]
  AixOperatingSystem->>AixOSProcess: create and update process
Loading

Possibly related PRs

  • oshi/oshi#3350: Adds AIX FFM support and related process wiring used by this refactor.
  • oshi/oshi#3390: Refactors the shared AIX AixOSProcess process implementation.

Poem

A bunny hops through AIX skies,
With shared process data in its eyes.
JNA and FFM now play,
While common code leads the way.
“Less hopping!” the rabbit cries.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 4.35% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main refactor: extracting the AIX operating-system base class and sharing the perfstat process carrier.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Jul 17, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.20%. Comparing base (1ef78c4) to head (e9f90a0).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #3469      +/-   ##
============================================
- Coverage     75.24%   75.20%   -0.04%     
  Complexity       76       76              
============================================
  Files           589      589              
  Lines         21528    21528              
  Branches       3592     3592              
============================================
- Hits          16198    16190       -8     
  Misses         3378     3378              
- Partials       1952     1960       +8     
Flag Coverage Δ
freebsd 27.70% <ø> (-0.01%) ⬇️
linux 32.25% <ø> (+0.02%) ⬆️
macos 32.78% <ø> (-0.04%) ⬇️
openbsd 27.04% <ø> (-0.02%) ⬇️
solaris 29.51% <ø> (+<0.01%) ⬆️
windows 40.95% <ø> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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.

Inline comments:
In
`@oshi-common/src/main/java/oshi/driver/common/unix/aix/AixPerfstatProcess.java`:
- Around line 19-24: Update the field documentation for proc_real_mem_data,
proc_real_mem_text, and real_inuse in the perfstat process structure to state
that the values are reported in kilobytes, replacing the incorrect “pages”
wording; leave the fields and downstream conversion unchanged.
🪄 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: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 25e3a325-1d59-4e49-93bd-e00df9cc737c

📥 Commits

Reviewing files that changed from the base of the PR and between 1ef78c4 and 7ec51db.

📒 Files selected for processing (11)
  • config/checkstyle-suppressions.xml
  • oshi-common/src/main/java/oshi/driver/common/unix/aix/AixPerfstatProcess.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/aix/AixOSProcess.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/aix/AixOperatingSystem.java
  • oshi-core-ffm/src/main/java/oshi/driver/unix/aix/perfstat/PerfstatProcessFFM.java
  • oshi-core-ffm/src/main/java/oshi/software/os/unix/aix/AixOSProcessFFM.java
  • oshi-core-ffm/src/main/java/oshi/software/os/unix/aix/AixOperatingSystemFFM.java
  • oshi-core/src/main/java/oshi/driver/unix/aix/perfstat/PerfstatProcessJNA.java
  • oshi-core/src/main/java/oshi/software/os/unix/aix/AixOSProcessJNA.java
  • oshi-core/src/main/java/oshi/software/os/unix/aix/AixOperatingSystemJNA.java
  • oshi-core/src/test/java/oshi/driver/unix/aix/perfstat/PerfstatJNATest.java
📜 Review details
⏰ Context from checks skipped due to timeout. (14)
  • GitHub Check: Codacy Static Code Analysis
  • 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: Test JDK 21, windows-latest
  • GitHub Check: Test JDK 25, ubuntu-latest (+ JNA==FFM)
  • GitHub Check: Test JDK 21, macos-latest
  • GitHub Check: Test JDK 26, ubuntu-latest
  • GitHub Check: Test JDK 25, windows-latest (+ JNA==FFM)
  • GitHub Check: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)
  • GitHub Check: Test JDK 25, FreeBSD (+ JNA==FFM)
  • GitHub Check: Test JDK 25, OpenBSD (+ JNA==FFM)
  • GitHub Check: Test JDK 25, OpenIndiana (+ JNA==FFM)
  • GitHub Check: Analyze (java)
🧰 Additional context used
🧠 Learnings (3)
📚 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/unix/aix/AixPerfstatProcess.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/aix/AixOperatingSystem.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/aix/AixOSProcess.java
📚 Learning: 2026-07-06T19:25:59.225Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3432
File: oshi-common/src/main/java/oshi/util/ExceptionUtil.java:26-56
Timestamp: 2026-07-06T19:25:59.225Z
Learning: In this repo’s SLF4J 1.x-compatible logging code, do not flag cases where a logger call uses SLF4J 1.6+ implicit-cause handling—e.g., `log.error("...{}", value, t)` (or similar with a single `{}` placeholder) where `t` is passed as the final/trailing argument. SLF4J will attach `t` as the log event’s cause with the full stack trace; this is equivalent to SLF4J 2.x’s fluent `atLevel(...).setCause(t).log(...)` and is intentionally used to preserve SLF4J 1.x runtime compatibility.

Applied to files:

  • oshi-common/src/main/java/oshi/driver/common/unix/aix/AixPerfstatProcess.java
  • oshi-core/src/main/java/oshi/driver/unix/aix/perfstat/PerfstatProcessJNA.java
  • oshi-core-ffm/src/main/java/oshi/driver/unix/aix/perfstat/PerfstatProcessFFM.java
  • oshi-core-ffm/src/main/java/oshi/software/os/unix/aix/AixOSProcessFFM.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/aix/AixOperatingSystem.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/aix/AixOSProcess.java
  • oshi-core/src/main/java/oshi/software/os/unix/aix/AixOSProcessJNA.java
  • oshi-core/src/main/java/oshi/software/os/unix/aix/AixOperatingSystemJNA.java
  • oshi-core-ffm/src/main/java/oshi/software/os/unix/aix/AixOperatingSystemFFM.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/aix/AixOSProcessJNA.java
  • oshi-core/src/main/java/oshi/software/os/unix/aix/AixOperatingSystemJNA.java
🔇 Additional comments (11)
oshi-common/src/main/java/oshi/driver/common/unix/aix/AixPerfstatProcess.java (1)

1-18: LGTM!

Also applies to: 25-29

config/checkstyle-suppressions.xml (1)

53-57: LGTM!

oshi-core-ffm/src/main/java/oshi/driver/unix/aix/perfstat/PerfstatProcessFFM.java (1)

25-25: LGTM!

Also applies to: 49-78

oshi-core/src/main/java/oshi/driver/unix/aix/perfstat/PerfstatProcessJNA.java (1)

12-12: LGTM!

Also applies to: 38-64

oshi-core/src/test/java/oshi/driver/unix/aix/perfstat/PerfstatJNATest.java (1)

30-30: LGTM!

Also applies to: 86-90

oshi-common/src/main/java/oshi/software/common/os/unix/aix/AixOperatingSystem.java (1)

1-251: LGTM!

oshi-common/src/main/java/oshi/software/common/os/unix/aix/AixOSProcess.java (1)

20-20: LGTM!

Also applies to: 40-48, 60-77, 103-113

oshi-core/src/main/java/oshi/software/os/unix/aix/AixOperatingSystemJNA.java (1)

15-67: LGTM!

oshi-core-ffm/src/main/java/oshi/software/os/unix/aix/AixOperatingSystemFFM.java (1)

12-49: LGTM!

Also applies to: 71-72

oshi-core-ffm/src/main/java/oshi/software/os/unix/aix/AixOSProcessFFM.java (1)

19-19: LGTM!

Also applies to: 36-38, 52-61

oshi-core/src/main/java/oshi/software/os/unix/aix/AixOSProcessJNA.java (1)

18-18: LGTM!

Also applies to: 35-37, 51-56

AIX was the only platform whose OperatingSystem JNA and FFM twins extended
AbstractOperatingSystem directly, with no common base, so they duplicated the
service/version/boot-time/installed-app logic and the perfstat-driven process
and thread enumeration.

Introduce a backend-neutral AixPerfstatProcess carrier (oshi-common) holding
the perfstat_process fields OSHI consumes; PerfstatProcessJNA maps its JNA
struct into it and PerfstatProcessFFM returns it in place of its private
ProcessInfo POJO. On top of that, extract an AixOperatingSystem base holding
all the shared logic plus the carrier-typed process/thread enumeration. The
twins keep only hooks: the perfstat/partition-config reads, the native
process/thread IDs, and the OSProcess/InternetProtocolStats/NetworkParams
factories.

AixOSProcess also unifies: its procCpu iteration (updateAttributes) and the
getrlimit open-file-limit skeleton move into the base behind an
AixPerfstatProcess[] supplier and a queryRlimitNofile hook, so the twins keep
only the native getrlimit, affinity, and address-space reads.

Behavior-preserving refactor; no CHANGELOG.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant