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

Merged
TH
3d ago
+109-7

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):

AcquisitionsBaseHead
2, readable31
3, first read unanswered42

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

Validation

Tested at fd5c42c8375051aebb265ce289c2624812d6a0b7 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.