Skip to content

perf(macos): reuse the helper fingerprint between unchanged calls - #5207

Merged
thymikee merged 2 commits into
mainfrom
perf/macos-helper-fingerprint-reuse
Nov 29, 2026
Merged

thymikee merged 2 commits into
mainfrom
perf/macos-helper-fingerprint-reuse

Conversation

@thymikee

@thymikee thymikee commented Nov 29, 2026 •

Copy link
Copy Markdown
Member

Summary

Every local macOS helper call read the Swift sources and ran swift --version before checking the installed helper.

The helper now remembers its fingerprint while:

  • the sources are unchanged: an installed package's are immutable for the process; a checkout's are stamped (path, device, inode, size, mtime), including additions and removals;
  • the selected Swift compiler (DEVELOPER_DIR or xcode-select, plus stamps of the compiler and any Xcode bundle version.plist) is unchanged;
  • the shared manifest and executable, still checked on every call, accept it.

Any other call reads and probes afresh, so a rebuild records what it compiles. A failed probe, or an unidentifiable compiler, is never remembered. Configured and provider helpers still skip this. The digest format is unchanged.

Before / after

No observable change: same helper, same rebuild triggers. Fingerprint resolution on one macOS host (Xcode 27.1, 30 samples each; "before" forces a full read and probe; at 7a3dbc1331):

Layout Before median / p90 After median / p90
checkout (17 Swift files) 289 / 637 ms 4.3 / 13.0 ms
installed (11) 164 / 259 ms 0.33 / 0.48 ms

Validation

At 4981629c94, helper-build.test.ts passes (9/9); with the previous helper-fingerprint.ts, the bundle version file test fails. OXC format and lint pass on the changed files. Remaining gates: CI.

Residual risk: a compiler swapped in place behind PATH or TOOLCHAINS is seen only after a daemon restart or when the shared helper stops matching. No independent review; self-reviewed.

🤖 Generated with Claude Code


Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

View guided diff Turn on auto-fix

Every local macOS helper invocation walked and read the Swift sources and ran
`swift --version` before it compared the shared install manifest. The helper
now remembers the fingerprint while the sources and the selected Swift compiler
are unchanged and the shared install carries it. The manifest and executable
are still read on every call, and a rebuild reads sources and compiler afresh.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@github-actions

github-actions Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Size Report

Metric Base Current Diff
Installed (including dependencies) 6.70 MB 6.70 MB +1.5 kB
Package (unpacked) 6.69 MB 6.70 MB +1.5 kB
Package (download) 2.04 MB 2.04 MB +584 B

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 22.3 ms 19.7 ms -2.7 ms
CLI --help 45.7 ms 44.1 ms -1.6 ms

@cubic-dev-ai cubic-dev-ai 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.

All reported issues were addressed across 3 files

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

An in-place toolchain replacement could keep the compiler's path, size, and
modification time. The key now also carries the selected bundle's version file
and each stamped file's device and inode.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@apex-sentinel-staging

Copy link
Copy Markdown

Apex Sentinel · ✅ Approve · review of 4981629

No open findings.

5 findings below minor hidden (user_settings.min_severity).

Reviewed with this repository's own Sentinel configuration (47e3fbe2758c).

💬 Talking to Sentinel

In a finding's thread, reply with:

Command What it does
@apex-sentinel-staging note <context> Adds context; Sentinel re-checks the cited code
@apex-sentinel-staging pivot <why> Says the finding is wrong; Sentinel re-checks the cited code
@apex-sentinel-staging like Marks the finding as useful
@apex-sentinel-staging dislike <why> Marks it as not useful, so it is not raised again

On this conversation, comment @apex-sentinel-staging review to run a full review once again.

@thymikee

Copy link
Copy Markdown
Member Author

The PR is ready at 4981629, and no change is required before merge.

Not blocking: these can be taken or left: remember nothing unless the swift that the command PATH resolves to is the /usr/bin/swift shim and TOOLCHAINS is unset, or accept explicitly that switching or upgrading such a toolchain can reuse a helper built by the old compiler (key); resolve the selected developer directory through one shared owner, so a missing or dangling selection link gets the same default fallback and does not reread sources and run swift --version on every call (copy); add ctimeMs to the file stamp, so an in-place write that restores mtime still rebuilds (stamp); and either stamp sources in both layouts or correct the "same rebuild triggers" claim in the PR description, because a hand-patched installed package no longer rebuilds on the next call (sources).

In this thread, the version.plist, device and inode part is fixed, so it can be resolved; the PATH and TOOLCHAINS part of compiler selection remains as the disclosed risk in the first note.

CI is green at this commit, with Proof skipped. The macOS smoke check passes, and by code reading its open "System Settings" --relaunch step reaches the first helper resolution; the logs do not show helper execution directly. Not verified here: no tests or PR code were run locally, and test validity was judged from the source; live evidence rests on the author's macOS timing run at 7a3dbc1 and the smoke check; reuse of the fingerprint was not observed live at 4981629; the timing table was not reproduced; the toolchain manager, TOOLCHAINS and missing selection link cases come from code reading only.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 29, 2026
@thymikee
thymikee merged commit ab4ba80 into main Nov 29, 2026
22 checks passed
@thymikee
thymikee deleted the perf/macos-helper-fingerprint-reuse branch November 29, 2026 15:19
thymikee added a commit that referenced this pull request Nov 29, 2026
…roc-first

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>

* origin/main:
  perf(apple): reuse the process identity for native-build cache locks (#5203)
  perf(apple): read the native-build toolchain identity with two concurrent probes (#5206)
  perf(macos): reuse the helper fingerprint between unchanged calls (#5207)
  docs(agents): add performance guidance (#5208)
  perf(daemon): classify a device claim owner only for refusals and settlement (#5210)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-human Valid work that needs human implementation, judgment, or maintainer merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant