Skip to content

feat(packages): install a per-chip toolchain slice when the mirror lists one (#1944 client half) - #1949

Merged
zackees merged 2 commits into
mainfrom
agent/toolchain-slice-client
Nov 7, 2026
Merged

zackees merged 2 commits into
mainfrom
agent/toolchain-slice-client

Conversation

@zackees

@zackees zackees commented Nov 7, 2026

Copy link
Copy Markdown
Member

Client half of #1944: an ESP32 toolchain install now prefers a published
per-chip slice, so the 168 MB unified download becomes the ~75 MB esp32s3 one.

What changes

ci/slice_toolchain.py (#1947) already emits one tar.zst per chip. Nothing
resolved them, so fbuild still downloaded the whole 660 MB tree. This adds the
resolving half:

  • variants.rs learns a second slice family: toolchain-xtensa-esp-elf is
    looked up in the @esp-toolchain shard, exactly like the SDK libs are looked
    up in @esp-libs. The RISC-V toolchain is deliberately not slice-capable
    -- its multilib directories are ISA variants (rv32imc/ilp32), not chips, so
    there is nothing chip-shaped to slice.
  • PackageBase gains an optional chip variant (with_slice_variant). When the
    mirror lists a slice for that chip, the archive comes from the slice; when it
    does not, the artifact's own URL is used, unchanged.
  • Esp32Toolchain::with_slice_variant + the orchestrator pass build.mcu, on
    both the build and the install --check paths.

The two rules that make it safe

A slice installs into its own chip-scoped directory (<version>+<chip>).
A slice ships one chip's SDK libraries; putting it in the shared directory
would let a later build for a different chip find a tree that looks installed
and fail at link. A whole archive keeps the shared directory, which serves
every chip, and the shared directory is preferred when it already exists -- so
a host that installed the full toolchain before slicing existed never
re-downloads, and two chips still get two correct trees.

A listed slice is authoritative. A corrupt slice fails the install instead
of quietly falling back to the full archive, matching the ESP libs contract:
a bad publish must be visible, not merely slow. Only "no slice published for
this chip" falls back to the whole archive.

The DiskCache index row is keyed by the chip-scoped version, so GC sees one row
per chip and LRU/installed_bytes stay truthful.

Tests

crates/fbuild-packages-fetch/src/chip_slice_tests.rs drives the real
staged_install against a local HTTP server and asserts what was not
downloaded
:

  • slice install -> lands at ...+esp32s3, sentinel written, is_cached(),
    and the request log is exactly ["/slice.tar.zst"] (the 4096-byte vendor
    archive is served and never asked for);
  • corrupt slice -> checksum mismatch, still exactly one request, no chip dir;
  • existing shared whole install -> returned as-is for two different chips, no
    request at all;
  • no published slice -> falls back to the vendor URL, installed chip-scoped;
  • chip paths are per-chip siblings of the shared path; one chip's slice never
    satisfies another chip.

variants.rs gains the selection matrix: toolchain slice chosen for the chip
it is listed for, whole archive for a chip without one, never for RISC-V.

Not in this PR

Publishing the slices (a publish_esp_slices.py-shaped uploader plus the
@esp-toolchain shard entry) and the end-to-end ESP32-S3 install measurement.
Until a shard exists the client takes the fallback path, which is exactly
today's behaviour.

Refs #1944.

…sts one

#1947 gave fbuild a slicer: one deterministic tar.zst per ESP32 chip, 75 MB
instead of the 168 MB unified toolchain. Nothing resolved those slices, so a
first ESP32-S3 install still downloaded the whole 660 MB tree.

This is the resolving half.

* `variants::slice_shard` is the single place that says which artifacts have
  per-chip slices: `@esp-libs` for the SDK libs, new `@esp-toolchain` for
  `toolchain-xtensa-esp-elf`. The RISC-V toolchain is never sliced -- its
  multilibs are ISA variants (rv32imc/ilp32), not chips.
* `PackageBase` gains an optional chip variant. When the mirror lists a slice
  for that chip the archive comes from the slice; when it does not, the
  artifact's own URL is used, unchanged.

Two rules carry the safety:

* A slice installs into its own chip-scoped directory (`<version>+<chip>`). A
  slice holds ONE chip's SDK libs, so the shared path would let a later build
  for another chip find a tree that looks installed and fail at link. A whole
  archive keeps the shared path, which serves every chip, and is preferred
  when it already exists -- a host that installed before slicing existed never
  re-downloads.
* A slice that IS listed is authoritative: a corrupt one fails the install
  instead of quietly fetching the full archive, matching the ESP libs
  contract. Only "no slice published for this chip" falls back.

`Esp32Toolchain::with_slice_variant` + the orchestrator pass `build.mcu` on
both the build and the `install --check` paths; `is_installed`, `get_info` and
the DiskCache row all follow the directory actually on disk.

Tests drive the real `staged_install` against a local HTTP server and assert
what was NOT downloaded: a slice install requests exactly the slice URL (the
vendor archive is served and never asked for), a corrupt slice fails with
`checksum mismatch` and still makes one request, an existing shared install is
returned for two different chips with no request, an unpublished slice falls
back to the vendor URL, and one chip's slice never satisfies another.

Refs #1944.
@coderabbitai

coderabbitai Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

`crates/fbuild-build-esp/src/esp32/orchestrator/packages.rs` sat at 999 LOC,
so passing the chip to the toolchain pushed it to 1001 and tripped the
"Reject .rs files over 1000 LOC" gate.

Move the inline `registry_toolchain_tests` module to its own file, the same
way `legacy_tests` is already split out (`#[path = ...]`). Pure move: the four
tests are unchanged and still pass; packages.rs drops to 847 LOC.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

1 participant