Skip to content

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

Closed

Description

@dbwiddis

Part of the recurring "macOS changed things again" maintenance. Split out of #3534, where it surfaced during the SMC sensor work but was left out of scope — the sensor work is chip-agnostic by design and does not depend on any of this.

The framing that matters: none of this needs new per-chip table entries, and none of it needs hardware I don't have. Everything required is already read by MacCentralProcessor and then discarded. Two of the three problems below are cases of the code fetching the right data and ignoring it in favour of a hardcoded list that stops at M4.

1. P-core/E-core classification is hardcoded, and stops at M4

MacCentralProcessor.java:59-61:

private static final Set<String> ARM_P_CORES = Stream
        .of("apple,firestorm arm,v8", "apple,avalanche arm,v8", "apple,everest arm,v8", "apple,donan arm,v8")
        .collect(Collectors.toSet());

Firestorm/Avalanche/Everest/Donan are M1/M2/M3/M4. An M5 or A-series P-core codename is not in the set, so efficiency is 0 for every core (line 331). That is not only a wrong PhysicalProcessor#getEfficiency() — queryCurrentFreq() branches on getEfficiency() > 0, so per-core frequency reporting degrades with it.

But macOS already reports this directly, chip-independently, and the code already reads it. From an M2 Max:

hw.nperflevels: 2
hw.perflevel0.physicalcpu: 8      hw.perflevel0.name: Performance
hw.perflevel1.physicalcpu: 4      hw.perflevel1.name: Efficiency

queryProcessorTopology() reads hw.nperflevels on line 328 — and then uses it only to size the cache list, while line 331 falls back to the hardcoded name set. Confirmed on an M2 Max, cores are ordered efficiency-first:

core 0-3    efficiency 0    apple,blizzard arm,v8
core 4-11   efficiency 1    apple,avalanche arm,v8

which lines up exactly with perflevel1.physicalcpu = 4 efficiency cores followed by perflevel0.physicalcpu = 8 performance cores.

So ARM_P_CORES should be deleted, not extended. A derivation has options, and the implementer should pick: group cores by their distinct compatible string (already in compatMap) and label the groups by matching group size against the perflevel*.physicalcpu counts; or rely on the efficiency-first ordering. Note the count-matching approach is ambiguous on a chip with an even split such as the base M1 (4+4), where ordering or another tiebreak is needed — worth handling explicitly rather than by accident.

2. The microarchitecture table is redundant with data already read

oshi.architecture.properties stops at M4:

apple.0x1b588bb3=ARM64 SoC: Firestorm + Icestorm
apple.0xda33d83d=ARM64 SoC: Avalanche + Blizzard
apple.0x8765edea=ARM64 SoC: Everest + Sawtooth
apple.0x5f4dea93=ARM64 SoC: M3 Pro (Lobos)
apple.0x6f5129ac=ARM64 SoC: M4 (Donan)

so getMicroarchitecture() returns Constants.UNKNOWN on M5 and on any A-series part.

The entries are, however, mechanically derivable from data the code already has. On this M2 Max the reported value is ARM64 SoC: Avalanche + Blizzard, and the two compatible strings are apple,avalanche arm,v8 and apple,blizzard arm,v8 — the string is exactly the performance codename plus the efficiency codename, capitalised. compatMap is built on line 327 and currently used only as a display string on the PhysicalProcessor.

Deriving it would cover every future chip with no table maintenance, while keeping the properties file as an override for parts whose marketing name differs from the codename pair (the M3 Pro (Lobos) entry is that case). Worth deciding whether the derived value or the table wins when both exist.

3. Latent, not currently reachable: the brand-string fallback misclassifies

When hw.cpufamily returns 0, queryProcessorId() parses the brand string:

int mSeries = ParseUtil.getFirstIntValue(cpuName);
switch (mSeries) {
    case 2:  family = M2_CPUFAMILY; break;
    case 3:  family = M3_CPUFAMILY; break;
    case 4:  family = M4_CPUFAMILY; break;
    default: family = M1_CPUFAMILY;
}

getFirstIntValue takes the first run of digits, so "Apple M5" → 5 → default → reported as M1, and "Apple A18 Pro" → 18 → default → also M1.

Being straight about severity: hw.cpufamily is non-zero on real macOS, so this does not currently execute on hardware. It is a latent trap rather than a live bug. If items 1 and 2 are done by derivation, this fallback matters even less — but silently claiming M1 for anything unrecognised is still the wrong default.

4. Housekeeping

M3_PRO_CPUFAMILY (MacCentralProcessor.java:74) is declared but never referenced in code; it exists only as a key in the properties file. The M1/M2/M3/M4 constants are likewise used only by the dead fallback in item 3.

Suggested shape

  1. Derive P/E from hw.perflevel* plus the existing compatMap; delete ARM_P_CORES.
  2. Derive the microarchitecture string from the compatible codename pair, keeping the properties file as an override.
  3. Stop defaulting unrecognised chips to M1 in the brand-string fallback.
  4. Remove the constants that become unused.

Items 1 and 2 are both verifiable on any Apple Silicon Mac — a correct derivation must keep reporting efficiency 0/1 and ARM64 SoC: Avalanche + Blizzard on an M2 Max, and equivalents on M1/M3/M4, so existing hardware is enough to prove it. That is a better position than adding table rows for chips nobody in the project owns.

Activity

  1. changed the title [-]macOS: Apple Silicon chip identification has not kept up with M5 and the A-series[/-] [+]macOS: derive Apple Silicon chip details at runtime instead of hardcoding per-chip tables[/+] on Jul 27, 2026
  2. dbwiddis commented on Jul 27, 2026

    @dbwiddis
    MemberAuthor

    Rewrote the body above. The original framing was wrong in a way worth recording rather than quietly editing away.

    It asked for apple.<family> table rows and new ARM_P_CORES entries for M5 and the A-series, and said both were blocked on hardware nobody here has. Checking what MacCentralProcessor already reads shows neither is true:

    • hw.nperflevels is read on line 328 and used only to size the cache list, while the P/E decision on line 331 falls back to the hardcoded name set. macOS reports the split directly: hw.perflevel0.name = Performance with 8 physical cores, hw.perflevel1.name = Efficiency with 4, on an M2 Max.
    • compatMap is built on line 327 and used only as a display string, yet it holds the very codenames the microarchitecture string is assembled from — apple,avalanche + apple,blizzard is exactly the reported ARM64 SoC: Avalanche + Blizzard.

    So the correct fix is to delete ARM_P_CORES rather than extend it, and the work is verifiable on existing Apple Silicon hardware rather than blocked on an M5. Requesting ioreg dumps from M5 owners, as the original text did, would have been asking for input to a table that should not exist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions