os: Processor.describe on Arm64 Linux and macOS (OS slice 3, step 2c of #127) #786

Closed
opened 2026-11-14 11:19:58 +00:00 by orion · 7 comments
Collaborator

Goal

Step 2c of #127 (OS slice 3): Processor.describe() on Arm64 Linux and Arm64 macOS answers Ok with vendor, model, caches and features, replacing the Unsupported arms of those two halves. Arm64 Windows stays Unsupported until step 2d.

Why the cut: the Arm64 description needs three system sources, a cache source per system (Linux /sys/devices/system/cpu/cpu0/cache/, macOS hw.l1dcachesize and siblings, Windows a new processorTopology native over GetLogicalProcessorInformationEx) and an uncompiled-here Windows C file. Linux and macOS use only std/os reads that exist or are one small native (getauxval), so they fit one PR; Windows follows as 2d. Only 2c is filed now, per the definition of ready.

Design record

docs/design/OS.md section 5.2 (ProcessorDescription, ProcessorFeature with Neon, Crc32, DotProduct, Sve, Sve2, Aes, Sha), section 7 "Linux" and "macOS" native tables (auxiliaryValue, Bsd.sysctl* by name, hw.optional.arm.*, /proc/cpuinfo), the "As built (step 2b)" note, slice 3 of section 10.

Scope

  • Processor.describe(): in the .Linux and .MacOs arms, an Architecture.current .Arm64 arm that calls describeArm64(...) of the per-system half; .Windows and every other architecture keep answering OsError.Unsupported("the processor description", ...).
  • Linux half: vendor from the CPU implementer field of /proc/cpuinfo (a pure parser with a table of the common implementer codes: 0x41 ARM, 0x61 Apple, 0x51 Qualcomm, 0x46 Fujitsu, 0xc0 Ampere; unknown code: ARM), model from model name or Hardware, else the vendor; features from getauxval(AT_HWCAP) and AT_HWCAP2 (Neon = asimd, Aes, Sha = sha1 and sha2, Crc32, DotProduct = asimddp, Sve, Sve2) through a pure decoder over two integers; caches from /sys/devices/system/cpu/cpu0/cache/index*/ (level, type, size, coherency_line_size) through a pure parser. Adds the native auxiliaryValue(kind: Int): Int64 to runtime/os/linux.c only if step 2a or 1 did not already; it is plain Direct, no outcome.
  • macOS half: vendor Apple, model from machdep.cpu.brand_string, features from hw.optional.arm.* (FEAT_AES, FEAT_SHA256, FEAT_CRC32, FEAT_DotProd, AdvSIMD; SVE is false on every Apple processor to date), caches from hw.l1dcachesize, hw.l1icachesize, hw.l2cachesize and hw.cachelinesize, all through Bsd.sysctl* by name; a name the system does not know reads as absent, never as an error.
  • packages on Arm64 Linux and macOS reuse the 2b functions (parsePackageCount, hw.packages), with 1 where they answer 0.
  • baseFrequency and maximumFrequency stay None (step 3).
  • Tests in std/os/tests/processor.test.trb: the implementer parser and the cache parser on captured /proc/cpuinfo and /sys texts of one Apple-Silicon Asahi Linux, one Graviton (Neoverse) and one x86 file (answers none); the hwcap decoder on made-up words with and without SVE; one machine-tolerant describe test that runs on the Arm64 CI machines only if one exists, otherwise on --every-target type checking.
  • docs/standard-library/os.md and the skills/ copy updated; the "As built" note of OS.md section 7 and the slice 3 row of section 10 say what 2c did and that Windows Arm64 is 2d.
  • Out of scope: Arm64 Windows (2d), frequencies (step 3), FreeBSD (#131), new ProcessorFeature cases.

Acceptance criteria

  • On Arm64 Linux and Arm64 macOS Processor.describe() answers Ok with non-empty vendor and model, logicalProcessors == Processor.logicalCount(), physicalCores == Processor.physicalCount(), features containing Neon, and at least one cache; where no Arm64 machine runs CI the same is checked by the pure parsers fed with captured texts.
  • Windows on Arm64, FreeBSD and the browser still answer OsError.Unsupported; torb check --every-target shows no compile error on any target.
  • The implementer parser maps 0x41, 0x61, 0x51, 0xc0 to their vendor names and an unknown or missing code to ARM; the hwcap decoder returns Sve and Sve2 only when their bits are set; the cache parser handles missing files and an empty text without trapping.
  • torb format --check clean on touched files; sh tools/gates.sh a green in forge CI; docs check and skills/ regeneration clean.

Seed impact

None expected: new std names and, at most, one plain Direct native in runtime/os/linux.c that the compiler does not look up by string. If CI shows otherwise, fall back to the two-commit rule.

Size

One PR, two Conventional Commits: feat(os): Arm64 feature and cache readers for Linux and macOS (natives if needed, pure parsers, tests) and feat(os): Processor.describe on Arm64 Linux and macOS (wiring, docs).

Dependencies

Step 2b (#543) landed (28ac17d5), 2a (#538) and step 1 (#488) landed. Part of #127; 2d (Arm64 Windows) and step 3 (frequencies) are not filed yet.

## Goal Step 2c of #127 (OS slice 3): `Processor.describe()` on Arm64 Linux and Arm64 macOS answers `Ok` with vendor, model, caches and features, replacing the `Unsupported` arms of those two halves. Arm64 Windows stays `Unsupported` until step 2d. Why the cut: the Arm64 description needs three system sources, a cache source per system (Linux `/sys/devices/system/cpu/cpu0/cache/`, macOS `hw.l1dcachesize` and siblings, Windows a new `processorTopology` native over `GetLogicalProcessorInformationEx`) and an uncompiled-here Windows C file. Linux and macOS use only `std/os` reads that exist or are one small native (`getauxval`), so they fit one PR; Windows follows as 2d. Only 2c is filed now, per the definition of ready. ## Design record `docs/design/OS.md` section 5.2 (`ProcessorDescription`, `ProcessorFeature` with `Neon`, `Crc32`, `DotProduct`, `Sve`, `Sve2`, `Aes`, `Sha`), section 7 "Linux" and "macOS" native tables (`auxiliaryValue`, `Bsd.sysctl*` by name, `hw.optional.arm.*`, `/proc/cpuinfo`), the "As built (step 2b)" note, slice 3 of section 10. ## Scope - `Processor.describe()`: in the `.Linux` and `.MacOs` arms, an `Architecture.current` `.Arm64` arm that calls `describeArm64(...)` of the per-system half; `.Windows` and every other architecture keep answering `OsError.Unsupported("the processor description", ...)`. - Linux half: `vendor` from the `CPU implementer` field of `/proc/cpuinfo` (a pure parser with a table of the common implementer codes: `0x41` ARM, `0x61` Apple, `0x51` Qualcomm, `0x46` Fujitsu, `0xc0` Ampere; unknown code: `ARM`), `model` from `model name` or `Hardware`, else the vendor; features from `getauxval(AT_HWCAP)` and `AT_HWCAP2` (`Neon` = `asimd`, `Aes`, `Sha` = `sha1` and `sha2`, `Crc32`, `DotProduct` = `asimddp`, `Sve`, `Sve2`) through a pure decoder over two integers; caches from `/sys/devices/system/cpu/cpu0/cache/index*/` (`level`, `type`, `size`, `coherency_line_size`) through a pure parser. Adds the native `auxiliaryValue(kind: Int): Int64` to `runtime/os/linux.c` only if step 2a or 1 did not already; it is plain `Direct`, no outcome. - macOS half: `vendor` `Apple`, `model` from `machdep.cpu.brand_string`, features from `hw.optional.arm.*` (`FEAT_AES`, `FEAT_SHA256`, `FEAT_CRC32`, `FEAT_DotProd`, `AdvSIMD`; SVE is `false` on every Apple processor to date), caches from `hw.l1dcachesize`, `hw.l1icachesize`, `hw.l2cachesize` and `hw.cachelinesize`, all through `Bsd.sysctl*` by name; a name the system does not know reads as absent, never as an error. - `packages` on Arm64 Linux and macOS reuse the 2b functions (`parsePackageCount`, `hw.packages`), with `1` where they answer 0. - `baseFrequency` and `maximumFrequency` stay `None` (step 3). - Tests in `std/os/tests/processor.test.trb`: the implementer parser and the cache parser on captured `/proc/cpuinfo` and `/sys` texts of one Apple-Silicon Asahi Linux, one Graviton (Neoverse) and one x86 file (answers none); the hwcap decoder on made-up words with and without SVE; one machine-tolerant `describe` test that runs on the Arm64 CI machines only if one exists, otherwise on `--every-target` type checking. - `docs/standard-library/os.md` and the `skills/` copy updated; the "As built" note of OS.md section 7 and the slice 3 row of section 10 say what 2c did and that Windows Arm64 is 2d. - Out of scope: Arm64 Windows (2d), frequencies (step 3), FreeBSD (#131), new `ProcessorFeature` cases. ## Acceptance criteria - [ ] On Arm64 Linux and Arm64 macOS `Processor.describe()` answers `Ok` with non-empty `vendor` and `model`, `logicalProcessors == Processor.logicalCount()`, `physicalCores == Processor.physicalCount()`, `features` containing `Neon`, and at least one cache; where no Arm64 machine runs CI the same is checked by the pure parsers fed with captured texts. - [ ] Windows on Arm64, FreeBSD and the browser still answer `OsError.Unsupported`; `torb check --every-target` shows no compile error on any target. - [ ] The implementer parser maps `0x41`, `0x61`, `0x51`, `0xc0` to their vendor names and an unknown or missing code to `ARM`; the hwcap decoder returns `Sve` and `Sve2` only when their bits are set; the cache parser handles missing files and an empty text without trapping. - [ ] `torb format --check` clean on touched files; `sh tools/gates.sh a` green in forge CI; docs check and `skills/` regeneration clean. ## Seed impact None expected: new std names and, at most, one plain `Direct` native in `runtime/os/linux.c` that the compiler does not look up by string. If CI shows otherwise, fall back to the two-commit rule. ## Size One PR, two Conventional Commits: `feat(os): Arm64 feature and cache readers for Linux and macOS` (natives if needed, pure parsers, tests) and `feat(os): Processor.describe on Arm64 Linux and macOS` (wiring, docs). ## Dependencies Step 2b (#543) landed (`28ac17d5`), 2a (#538) and step 1 (#488) landed. Part of #127; 2d (Arm64 Windows) and step 3 (frequencies) are not filed yet.
Author
Collaborator

[loop:torbscript] claim implement by session:loop-torbscript-20261114-1708 until 2026-11-14T22:08:00Z

[loop:torbscript] claim implement by session:loop-torbscript-20261114-1708 until 2026-11-14T22:08:00Z
Author
Collaborator

[loop:torbscript] implement: opened #789 (2 commits: Arm64 readers + natives/tests, then the describe wiring + docs; verified: only commit format via tools/check-commits.sh, the diff read through; unverified until CI: torb check --every-target, format, tests, hand-edited machine_natives.c/torb_natives.h/NATIVES.md and the skills/ copy, seed gate). next: waiting (CI on the PR, then review)

[loop:torbscript] implement: opened https://git.torb.dev/torbscript/language/pulls/789 (2 commits: Arm64 readers + natives/tests, then the describe wiring + docs; verified: only commit format via tools/check-commits.sh, the diff read through; unverified until CI: torb check --every-target, format, tests, hand-edited machine_natives.c/torb_natives.h/NATIVES.md and the skills/ copy, seed gate). next: waiting (CI on the PR, then review)
Author
Collaborator

[loop:torbscript] release implement by session:loop-torbscript-20261114-1708

[loop:torbscript] release implement by session:loop-torbscript-20261114-1708
Author
Collaborator

[loop:torbscript] claim implement by session:loop-torbscript-20261114-1932 until 2026-11-14T22:32:00Z

[loop:torbscript] claim implement by session:loop-torbscript-20261114-1932 until 2026-11-14T22:32:00Z
Author
Collaborator

[loop:torbscript] implement: PR #789 history rewritten so the style commit is folded into "feat(os): Arm64 feature and cache readers for Linux and macOS" (fixup); two valid Conventional Commits remain, new head 5d8feef0 (was 0e10e534), force-pushed with --force-with-lease. Verified locally: git diff 0e10e534 HEAD is empty (tree identical), sh tools/check-commits.sh 74605bb2 HEAD passes. Unverified until CI: all checks (commit messages, what the change touches, gates, pdisc were pending right after the push). next: waiting (CI on the PR, then review)

[loop:torbscript] implement: PR #789 history rewritten so the `style` commit is folded into "feat(os): Arm64 feature and cache readers for Linux and macOS" (fixup); two valid Conventional Commits remain, new head 5d8feef0 (was 0e10e534), force-pushed with --force-with-lease. Verified locally: `git diff 0e10e534 HEAD` is empty (tree identical), `sh tools/check-commits.sh 74605bb2 HEAD` passes. Unverified until CI: all checks (commit messages, what the change touches, gates, pdisc were pending right after the push). next: waiting (CI on the PR, then review)
Author
Collaborator

[loop:torbscript] release implement by session:loop-torbscript-20261114-1932

[loop:torbscript] release implement by session:loop-torbscript-20261114-1932
argus closed this issue 2026-11-14 20:40:21 +00:00
Author
Collaborator

[orion] status: PR #789 (Processor.describe on Arm64 Linux and macOS) was merged by argus as 40bd5cabf. Post-merge steps are complete: the PR has no 'After merge' section and the repo has no x.y.z release tags (only nightly-YYYYMMDD tags), so no release was cut. Main CI on 40bd5cabf was still pending (ci gates, commit messages, what the change touches, pdisc, site:edge) after a 10 minute wait, so CI is not verified green. Next step: check the commit status on 40bd5cabf and file a follow-up if a gate fails.

[orion] status: PR #789 (Processor.describe on Arm64 Linux and macOS) was merged by argus as 40bd5cabf. Post-merge steps are complete: the PR has no 'After merge' section and the repo has no x.y.z release tags (only nightly-YYYYMMDD tags), so no release was cut. Main CI on 40bd5cabf was still pending (ci gates, commit messages, what the change touches, pdisc, site:edge) after a 10 minute wait, so CI is not verified green. Next step: check the commit status on 40bd5cabf and file a follow-up if a gate fails.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
torbscript/language#786
No description provided.