Skip to content

Derive Apple Silicon chip details at runtime - #3541

Merged
dbwiddis merged 2 commits into
oshi:masterfrom
dbwiddis:mac-derive-chip-details
Jul 28, 2026
Merged

dbwiddis merged 2 commits into
oshi:masterfrom
dbwiddis:mac-derive-chip-details

Conversation

@dbwiddis

@dbwiddis dbwiddis commented Jul 28, 2026 •

Copy link
Copy Markdown
Member

Closes #3537.

macOS chip identification came from hardcoded tables that stop at the M4, so an M5 or any A-series part is misreported. Everything needed to avoid those tables is already read from the IORegistry and then discarded.

Core classification

ARM_P_CORES was a set of four core codenames — firestorm/avalanche/everest/donan, i.e. M1–M4. An unlisted codename left efficiency 0 for every core, which is both a wrong PhysicalProcessor#getEfficiency() and a degraded queryCurrentFreq(), since that branches on getEfficiency() > 0.

The cpuN nodes already walked for compatible also carry cluster-type, a single letter naming the cluster:

cpu0-3    cluster-type = <"E">    compatible = <"apple,blizzard","ARM,v8">
cpu4-11   cluster-type = <"P">    compatible = <"apple,avalanche","ARM,v8">

That answers the question directly, for any chip, with no table. It's read in the same pass as compatible, and RegistryEntry.getByteArrayProperty is already generic — so neither the JNA nor the FFM backend changes.

Where cluster-type is unavailable the codenames still group the cores, ordered by core number (macOS numbers efficiency cores first) and cross-checked against hw.perflevel0.physicalcpu where that count is unambiguous. That reproduces exactly what the deleted table produced, so a machine without cluster-type is no worse off than today.

hw.nperflevels is deliberately not used to detect heterogeneity — it did not exist before macOS 12, so requiring it would misclassify an M1 running macOS 11. It keeps its existing job of sizing the cache loop.

Microarchitecture

Assembled from the same codenames, so an unlisted chip is described rather than reported unknown. The architecture table is consulted first and still wins, because an entry may carry a curated name a derivation cannot reproduce — M3 Pro (Lobos) and M4 (Donan) are exactly that case. Every chip currently in the table is byte-for-byte unchanged.

This needs a new ProcessorIdentifier constructor. japicmp reports it as +++ NEW CONSTRUCTOR with Semantic versioning suggestion: 0.0.1, so no version bump is required — verified by running verify, not assumed.

Also

Removes the brand-string fallback that reported any unrecognised chip as an M1 ("Apple M5" → 5 → default → M1), and the family constants only it used. A missing hw.cpufamily now leaves the family zero, which misses the table and falls through to the derived description.

⚠️ This deletes protected static final constants (M1/M2/M3/M3_PRO/M4_CPUFAMILY) from a public but non-@PublicApi class. Nothing in the project referenced them; a downstream subclass theoretically could.

Verification

Live on an M2 Max — identical to before:

microarch      = ARM64 SoC: Avalanche + Blizzard
core 0-3       eff=0  apple,blizzard arm,v8
core 4-11      eff=1  apple,avalanche arm,v8
currentFreq    E 2.42 GHz / P 3.70 GHz

Those eff values now come from cluster-type, since ARM_P_CORES is gone — so the live run exercises the new path end to end.

15 hardware-free fixture tests covering M2 Max 8+4, M1's ambiguous 4+4 even split, cluster-type absent, partial cluster-type propagated by codename, cluster-type with no codename, perf-level count overriding core ordering, unrecognised cluster letters, homogeneous cores, no properties at all, and a fabricated future chip (apple,hydra/apple,coyote) that classifies correctly and derives ARM64 SoC: Hydra + Coyote — the case that fails without this change.

The strongest check reads the shipped oshi.architecture.properties and asserts the derived string equals the entry already published for M1, M2 and M3. It asserts those entries are non-null first, so it cannot pass vacuously if the table fails to load.

Full gate clean on oshi-common,oshi-core,oshi-core-ffm, clean full-reactor install, 0 tests failed. NativeComparisonTest passes including processorIdentifier() and processorTopology(), so JNA/FFM parity holds.

Summary by CodeRabbit

  • Bug Fixes
    • Corrected Apple Silicon efficiency core classification on newer chips by using runtime per-core hardware data.
  • Improvements
    • More accurate Apple processor microarchitecture detection, using derived values when the curated architecture table has no matching entry.
  • Documentation
    • Clarified that Apple entries in architecture configuration are optional and override derived detection when present.
  • Tests
    • Added expanded unit coverage for Apple core classification and microarchitecture precedence/fallback behavior.

macOS chip identification came from hardcoded tables that stopped at the
M4, so an M5 or an A-series part was misreported. Everything needed to
avoid those tables is already read from the IORegistry and then
discarded.

Core classification came from ARM_P_CORES, a set of four core codenames
covering M1 through M4. An unlisted codename left the efficiency class 0
for every core, which is both a wrong PhysicalProcessor#getEfficiency
and a degraded queryCurrentFreq, since that branches on getEfficiency.
The cpuN nodes already walked for the compatible property also carry
cluster-type, a single letter naming the cluster as performance or
efficiency, which answers this directly and for any chip. That property
is now read in the same pass, so neither the JNA nor the FFM backend
changes.

Where cluster-type is unavailable the codenames still group the cores,
ordered by core number since macOS numbers efficiency cores first, and
cross-checked against hw.perflevel0.physicalcpu where that count is
unambiguous. That reproduces what the deleted table produced, so a
machine without cluster-type is no worse off than before. Note that
hw.nperflevels is deliberately not used to detect heterogeneity: it did
not exist before macOS 12, so requiring it would misclassify an M1
running macOS 11.

The microarchitecture is likewise assembled from the codenames, so an
unlisted chip is described rather than reported as unknown. The
architecture table is consulted first and still wins, because an entry
may carry a curated name a derivation cannot reproduce, as the M3 Pro
and M4 entries do. Passing the derived value needs a new
ProcessorIdentifier constructor; japicmp reports the addition as a patch
level change, so no version bump is required.

Also removes the brand string fallback that reported any unrecognized
chip as an M1, and the family constants that only it used. A missing
hw.cpufamily now leaves the family zero, which misses the table and
falls through to the derived description.

Verified on an M2 Max: the microarchitecture, the per-core efficiency
classes, and the split between efficiency and performance core
frequencies are all unchanged.
@coderabbitai

coderabbitai Bot commented Jul 28, 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 Plus

Run ID: b012bdab-4435-4f47-b44c-65f18a085196

📥 Commits

Reviewing files that changed from the base of the PR and between 932314c and 486633d.

📒 Files selected for processing (3)
  • CHANGELOG.md
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacCentralProcessor.java
  • oshi-common/src/test/java/oshi/hardware/common/platform/mac/MacCentralProcessorTest.java
🚧 Files skipped from review as they are similar to previous changes (2)
  • CHANGELOG.md
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacCentralProcessor.java
📜 Recent review details
⏰ Context from checks skipped due to timeout. (6)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Test JDK 25, ubuntu-latest (+ JNA==FFM)
  • GitHub Check: Test JDK 25, windows-latest (+ JNA==FFM)
  • GitHub Check: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)
  • GitHub Check: Test JDK 25, macos-latest (+ JNA==FFM)
  • GitHub Check: Analyze (java)
🔇 Additional comments (3)
oshi-common/src/test/java/oshi/hardware/common/platform/mac/MacCentralProcessorTest.java (3)

11-28: LGTM!


160-382: LGTM!


457-468: LGTM!


📝 Walkthrough

Walkthrough

Apple Silicon processor detection now derives core efficiency classes and microarchitecture descriptions from macOS IORegistry data. Processor identifiers retain architecture-property overrides and use derived values as fallback, with expanded tests and changelog documentation.

Changes

Apple Silicon identification

Layer / File(s) Summary
Processor microarchitecture fallback
oshi-common/src/main/java/oshi/hardware/CentralProcessor.java
ProcessorIdentifier accepts an optional derived microarchitecture and uses it only when architecture-property lookups do not resolve a value.
macOS core-property derivation
oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacCentralProcessor.java
IORegistry compatible and cluster-type properties are decoded to derive per-core efficiency classes, compatible codenames, and runtime microarchitecture descriptions.
Fallback and derivation coverage
oshi-common/src/test/java/oshi/hardware/..., oshi-common/src/main/resources/oshi.architecture.properties, CHANGELOG.md
Tests cover precedence, fallback, core classification, and future-chip cases; Apple mapping comments and the changelog are updated.

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

Sequence Diagram(s)

sequenceDiagram
  participant MacCentralProcessor
  participant IORegistry
  participant PhysicalProcessor
  participant ProcessorIdentifier
  MacCentralProcessor->>IORegistry: Read compatible and cluster-type properties
  IORegistry-->>MacCentralProcessor: Return per-core values
  MacCentralProcessor->>MacCentralProcessor: Derive efficiency classes
  MacCentralProcessor->>PhysicalProcessor: Populate core efficiency and codename
  MacCentralProcessor->>MacCentralProcessor: Derive microarchitecture
  MacCentralProcessor->>ProcessorIdentifier: Pass derived microarchitecture
Loading

Possibly related PRs

  • oshi/oshi#3264: Both PRs modify the macOS IOKit/IORegistry querying flow in MacCentralProcessor.

Poem

A rabbit watched the Apple cores align,
Performance and efficiency in a tidy design.
Codenames sprang from the registry’s glow,
Unknowns found fallbacks where they should go.
“Hop to the tests!” cried the rabbit with cheer.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: deriving Apple Silicon chip details at runtime.
Linked Issues check ✅ Passed The code and tests address the linked issue by deriving core classification and microarchitecture at runtime while preserving architecture-table overrides.
Out of Scope Changes check ✅ Passed The changes stay within the Apple Silicon runtime-derivation scope and add only related tests, docs, and cleanup.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ 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 28, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.11650% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.96%. Comparing base (8948ac4) to head (486633d).

Files with missing lines Patch % Lines
...dware/common/platform/mac/MacCentralProcessor.java 95.87% 0 Missing and 4 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #3541      +/-   ##
============================================
- Coverage     78.98%   78.96%   -0.02%     
- Complexity       76     3656    +3580     
============================================
  Files           699      699              
  Lines         24083    24160      +77     
  Branches       3986     4015      +29     
============================================
+ Hits          19021    19079      +58     
- Misses         2879     2889      +10     
- Partials       2183     2192       +9     
Flag Coverage Δ
linux 35.68% <88.34%> (+0.24%) ⬆️
macos 36.61% <96.11%> (+0.19%) ⬆️
windows 43.86% <88.34%> (+0.21%) ⬆️

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.

🧹 Nitpick comments (3)
CHANGELOG.md (1)

9-9: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Entry is inserted out of PR-number order (3541 before 3536). Content accurately matches the implementation; ordering only.

🤖 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 `@CHANGELOG.md` at line 9, Move the CHANGELOG entry for PR `#3541` below the
existing PR `#3536` entry so the changelog remains ordered by PR number, while
preserving the entry’s content unchanged.
oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacCentralProcessor.java (2)

271-278: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Simplify the perf-level tie-break condition.

firstMatches != (ordered.get(1).size() == topPerfLevelCores) && firstMatches reduces to firstMatches && ordered.get(1).size() != topPerfLevelCores, which reads directly as "only the first group matches". Behavior is correct as written; this is readability only.

♻️ Proposed simplification
-        if (ordered.size() == 2 && topPerfLevelCores > 0) {
-            boolean firstMatches = ordered.get(0).size() == topPerfLevelCores;
-            // Only decisive when exactly one group matches; an even split such as the base M1's 4+4 leaves the
-            // ordering to decide instead.
-            if (firstMatches != (ordered.get(1).size() == topPerfLevelCores) && firstMatches) {
-                Collections.reverse(ordered);
-            }
-        }
+        if (ordered.size() == 2 && topPerfLevelCores > 0
+                // Only decisive when exactly the first group matches the highest perf level's core count; an even
+                // split such as the base M1's 4+4 leaves the ordering to decide instead.
+                && ordered.get(0).size() == topPerfLevelCores && ordered.get(1).size() != topPerfLevelCores) {
+            Collections.reverse(ordered);
+        }
🤖 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-common/src/main/java/oshi/hardware/common/platform/mac/MacCentralProcessor.java`
around lines 271 - 278, In the perf-level ordering logic, simplify the nested
condition in MacCentralProcessor so it directly checks that firstMatches is true
and the second group size differs from topPerfLevelCores. Preserve the existing
reverse behavior and tie-handling for evenly split groups.

334-360: 🩺 Stability & Availability | 🔵 Trivial | 💤 Low value

getIdString() is dereferenced without a null check.

PhysicalProcessor's public 4-arg constructor accepts any idString, so a null value would NPE here. Internal call sites always pass a non-null string, so this is defensive only.

🛡️ Optional guard
         for (PhysicalProcessor processor : physicalProcessors) {
-            Matcher m = APPLE_CORE.matcher(processor.getIdString().toLowerCase(Locale.ROOT));
+            String idString = processor.getIdString();
+            if (idString == null) {
+                continue;
+            }
+            Matcher m = APPLE_CORE.matcher(idString.toLowerCase(Locale.ROOT));
🤖 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-common/src/main/java/oshi/hardware/common/platform/mac/MacCentralProcessor.java`
around lines 334 - 360, Update deriveMicroarchitecture to guard
processor.getIdString() before calling toLowerCase(Locale.ROOT) or matching it,
skipping processors whose ID string is null while preserving the existing
codename collection and sorting behavior.
🤖 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.

Nitpick comments:
In `@CHANGELOG.md`:
- Line 9: Move the CHANGELOG entry for PR `#3541` below the existing PR `#3536`
entry so the changelog remains ordered by PR number, while preserving the
entry’s content unchanged.

In
`@oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacCentralProcessor.java`:
- Around line 271-278: In the perf-level ordering logic, simplify the nested
condition in MacCentralProcessor so it directly checks that firstMatches is true
and the second group size differs from topPerfLevelCores. Preserve the existing
reverse behavior and tie-handling for evenly split groups.
- Around line 334-360: Update deriveMicroarchitecture to guard
processor.getIdString() before calling toLowerCase(Locale.ROOT) or matching it,
skipping processors whose ID string is null while preserving the existing
codename collection and sorting behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: b6b6f937-7ea1-4b70-b0dd-e5efab2661c5

📥 Commits

Reviewing files that changed from the base of the PR and between 8948ac4 and 932314c.

📒 Files selected for processing (6)
  • CHANGELOG.md
  • oshi-common/src/main/java/oshi/hardware/CentralProcessor.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacCentralProcessor.java
  • oshi-common/src/main/resources/oshi.architecture.properties
  • oshi-common/src/test/java/oshi/hardware/CentralProcessorTest.java
  • oshi-common/src/test/java/oshi/hardware/common/platform/mac/MacCentralProcessorTest.java
📜 Review details
⏰ Context from checks skipped due to timeout. (7)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Test JDK 26, ubuntu-latest
  • GitHub Check: Test JDK 25, windows-latest (+ JNA==FFM)
  • GitHub Check: Test JDK 25, ubuntu-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 (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/hardware/CentralProcessor.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacCentralProcessor.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/hardware/CentralProcessor.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacCentralProcessor.java
📚 Learning: 2026-04-12T19:34:56.879Z
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:56.879Z
Learning: In OSHI’s Java platform implementations, `PhysicalProcessor.getEfficiency()` / `EfficiencyClass` follow the same convention as Windows `PROCESSOR_RELATIONSHIP.EfficiencyClass`: a *higher* numeric efficiency class value represents *greater performance* and *less efficiency* (typically P-cores higher than E-cores). When reviewing, do not treat cases where P-cores are assigned higher efficiency/class values as a bug—this is intentional cross-platform consistency.

Applied to files:

  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacCentralProcessor.java
🔇 Additional comments (7)
oshi-common/src/main/java/oshi/hardware/CentralProcessor.java (1)

835-835: LGTM!

Also applies to: 869-889, 1069-1075

oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacCentralProcessor.java (3)

12-15: LGTM!

Also applies to: 37-37, 64-68, 172-197


226-269: LGTM!

Also applies to: 279-291, 299-324


431-431: LGTM!

Also applies to: 440-444, 471-471, 487-497

oshi-common/src/main/resources/oshi.architecture.properties (1)

337-340: LGTM!

oshi-common/src/test/java/oshi/hardware/CentralProcessorTest.java (1)

21-21: LGTM!

Also applies to: 121-146

oshi-common/src/test/java/oshi/hardware/common/platform/mac/MacCentralProcessorTest.java (1)

11-28: LGTM!

Also applies to: 160-285, 286-352, 427-427, 436-438

deriveEfficiencyClasses discarded the cluster-type values it had already
read whenever they did not cover every core. Strategy 3 began by clearing
the map, and it also aborts when any core lacks a codename, so a machine
where some cpuN nodes expose no readable properties fell all the way
through to the class 0 default. Cores that had reported cluster-type P
were then classified as efficiency cores, which is worse than the
codename table this replaced and re-introduces the degraded
queryCurrentFreq this change set out to fix. A cluster-type reading is
exact, so those values are now kept and only the remaining cores fall to
the default; the codename grouping applies only when cluster-type
classified nothing at all.

The propagation step also revisited every core rather than only the
unclassified ones, so a core that reported its own cluster-type could be
overwritten by a value inferred from another core sharing its codename,
contradicting the documented intent of applying the mapping to the other
cores. It now skips cores that are already classified.

Also simplifies the perf-level tie-break condition to a plain
conjunction and restores the CHANGELOG entry to PR number order, both
per review feedback.
@dbwiddis

Copy link
Copy Markdown
Member Author

@coderabbitai thanks — addressed in 486633d.

CHANGELOG ordering — fixed, #3541 now follows #3536.

Simplify the perf-level tie-break — fixed, adopted essentially as proposed. firstMatches != (...) && firstMatches is now a plain conjunction.

getIdString() null check — skipping. deriveMicroarchitecture is package-private and its only call site passes getPhysicalProcessors(), whose elements this class constructs with a non-null idString ("" at minimum, via props.getA() == null ? "" : ...). The guard would be unreachable.


Reviewing this on a second machine also turned up two real bugs in deriveEfficiencyClasses that the nitpick pass missed, both now fixed:

  1. Partial cluster-type readings were discarded. Strategy 3 opened with efficiencyMap.clear(), and it also aborts when any core lacks a codename — so where some cpuN nodes expose no readable properties, cores that had reported cluster-type = P fell through to the class 0 default:

    cores 0-3 = apple,everest + cluster-type P; cores 4-7 = no properties
    before:  0 0 0 0 0 0 0 0     <- every P core misclassified
    after:   1 1 1 1 0 0 0 0
    

    That was worse than the codename table this replaces, and it re-introduced the degraded queryCurrentFreq() the PR sets out to fix. cluster-type is exact, so those values are now kept and only the remainder defaults; codename grouping applies only when cluster-type classified nothing at all.

  2. Propagation could overwrite a core's own reading. The strategy-2 loop revisited every core, not just unclassified ones, so a core reporting its own cluster-type = E could be overwritten to 1 by a sibling sharing its codename — contradicting the javadoc's "applied to the other cores". It now skips already-classified cores.

Two regression tests added for these.

Verified on an M3 Pro (6+6), which is a different chip from the M2 Max in the PR description and exercises the even-split path where hw.perflevel0.physicalcpu is ambiguous and core ordering decides: E cores 0-5 @ 2.75 GHz, P cores 6-11 @ 4.06 GHz, ARM64 SoC: M3 Pro (Lobos) from the table as intended. oshi-common 1168 tests pass, Spotless/Checkstyle clean, and NativeComparisonTest processorIdentifier()/processorTopology() pass so JNA/FFM parity holds.

@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo '--- commit summary ---'
git show --stat --oneline 486633d

echo
echo '--- relevant follow-up diff ---'
git show --format=fuller --find-renames 486633d -- \
  CHANGELOG.md \
  oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacCentralProcessor.java \
  oshi-common/src/test/java/oshi/hardware/common/platform/mac/MacCentralProcessorTest.java

echo
echo '--- MacCentralProcessor outline ---'
ast-grep outline oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacCentralProcessor.java \
  --items all --type method --match 'deriveEfficiencyClasses|deriveMicroarchitecture|initProcessorCounts'

echo
echo '--- implementation and construction-site context ---'
rg -n -A100 -B15 \
  'deriveEfficiencyClasses\s*\(|deriveMicroarchitecture\s*\(|new PhysicalProcessor\s*\(' \
  oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacCentralProcessor.java

echo
echo '--- regression-test context ---'
rg -n -A55 -B8 \
  'partial|propagat|cluster.type|deriveEfficiencyClasses' \
  oshi-common/src/test/java/oshi/hardware/common/platform/mac/MacCentralProcessorTest.java

Length of output: 44176


@dbwiddis Confirmed in 486633d:

  • The CHANGELOG ordering and perf-level tie-break simplification are correct.
  • Exact partial cluster-type readings are retained, with only unclassified cores defaulting to class 0.
  • Codename propagation now preserves each core’s direct cluster-type result.
  • Both cases have focused regression coverage.

Your getIdString() rationale is also correct: initProcessorCounts() normalizes absent compatible values to "", so the production deriveMicroarchitecture(getPhysicalProcessors()) path cannot contain a null ID string. I’m withdrawing that nit.

Nice catch on the partial-readings regression—preserving exact IORegistry data is the right precedence. 🐇


✏️ Learnings added
Learnt from: dbwiddis
URL: https://github.com/oshi/oshi/pull/3541

Timestamp: 2026-07-28T18:20:41.660Z
Learning: In `oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacCentralProcessor.java`, `MacCentralProcessor.initProcessorCounts()` constructs every `PhysicalProcessor` with a non-null ID string: an absent IORegistry `compatible` property is normalized to `""`. Therefore, the production call `MacCentralProcessor.deriveMicroarchitecture(getPhysicalProcessors())` may safely call `PhysicalProcessor#getIdString()` without a null guard.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

@dbwiddis
dbwiddis merged commit 8639cd2 into oshi:master Jul 28, 2026
16 checks passed
@dbwiddis
dbwiddis deleted the mac-derive-chip-details branch July 29, 2026 00:30
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.

macOS: derive Apple Silicon chip details at runtime instead of hardcoding per-chip tables

1 participant