Skip to content

perf(apple): reuse the process identity for native-build cache locks - #5203

Merged
thymikee merged 2 commits into
mainfrom
perf/apple-native-build-lock-owner
Nov 29, 2026
Merged

thymikee merged 2 commits into
mainfrom
perf/apple-native-build-lock-owner

Conversation

@thymikee

@thymikee thymikee commented Nov 29, 2026 •

Copy link
Copy Markdown
Member

Summary

Fold and bridge cache acquisitions lock before testing for a cached binary, so even a hit builds a lock owner record. Each one looked up this process's start time in the process table.

The record now takes PID and start time from readCurrentOwnerIdentity(), the host-kit owner of that identity. It keeps the first readable answer for the life of the process and asks again after an unreadable one. Cache keys, cache verification and foreign-owner checks are unchanged.

Own start-time reads, counted by the new test (/proc hidden, so every read goes through the process table):

Acquisitions Base Head
2, readable 3 1
3, first read unanswered 4 2

On Linux outside the test, the read comes from /proc, so the saved process spawn applies to macOS hosts.

Validation

Tested at fd5c42c on macOS:

  • vitest run --project unit-core on native-build/host-lock.test.ts and native-build/cache.test.ts: 5 passed.
  • With base host.ts, both new tests fail on the read count.
  • oxfmt and oxlint on the changed files: clean.

Typecheck, layering, coverage and the full unit suite are CI obligations. No device run: lock record contents are unchanged. Self-review was a re-read of the diff; no independent reviewer ran.

🤖 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 fold and bridge cache acquisition read this process's start time from
the process table. Take the lock owner from readCurrentOwnerIdentity(),
which remembers the first readable answer and retries an unreadable one.

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 -20 B
Package (unpacked) 6.69 MB 6.69 MB -20 B
Package (download) 2.04 MB 2.04 MB -19 B

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 21.6 ms 22.2 ms +0.7 ms
CLI --help 49.0 ms 47.8 ms -1.1 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 2 files

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

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

@apex-sentinel-staging

Copy link
Copy Markdown

Apex Sentinel · ✅ Approve · review of a5af792

No open findings.

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

a5af792 is ready, with no code problems found.

Not blocking: take or leave a follow-up issue so that every lock owner for the current process gets its identity from readCurrentOwnerIdentity (existing code outside this diff still calls readProcessStartTime(process.pid) on each acquisition in the Swift host, the Apple runner and the web browser tool), and so that the second stored identity in runner-lease.ts, which also keeps a null answer, is reviewed.

The Windows test thread no longer applies and can be resolved, because both tests in native-build/host-lock.test.ts are now skipped on Windows.

All 21 checks pass at this head.

Not verified here: the new tests and their failure on the base were assessed by reading the code, without a local run, and the read counts and the saved process spawn were not measured on a live macOS daemon. The local validation in the PR description names fd5c42c, and the head adds only the Windows skip in the test file.

Nothing else from this review needs to happen before merge.

@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 a0c616c into main Nov 29, 2026
21 checks passed
@thymikee
thymikee deleted the perf/apple-native-build-lock-owner branch November 29, 2026 15:20
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