Repository navigation
perf(harness-ops): read the cache-content check's streams from a file, not a pipe - #12637
Conversation
…, not a pipe bash reads a pipe one byte per read() call because it cannot seek back over bytes past the delimiter, so `mapfile -d ''` from a process substitution cost one syscall per byte of git ls-tree, find and check-ignore output: 2,198,223 read() calls for the 17,491-entry ls-tree alone, 571 when the same bytes come from a file. Each stream is now written to one private temporary file and read back from it. The tree and cache joins also find each path's owning source directory and install root once per directory instead of once per file. Output is byte-identical on a 91-install fixture and on this host's real install state. Refs: #12541 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01VcuponMacsFYBfNzLKb3ws
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
claude-security-review reviewed Security review: PR #12637, incremental since
|
|
claude-review reviewed Code review (incremental since
|
…bash only bash 5.2's mapfile.def sets unbuffered_read = 1 under __CYGWIN__ for every descriptor, and read.def treats all input as a pipe there, so a Cygwin or MSYS2 bash still reads one byte per call from the spooled file. The changelog fragment and the spool comment now say where the block reads apply. Refs: #12541 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01VcuponMacsFYBfNzLKb3ws
Post-merge mutation testingKilled 2, survived 5, timeout 0, no coverage 0, invalid 0, not run 0.
Surviving mutants
The run's summary has the full report. |
Refs: #12541
Summary
The cache-content check (
/harness-ops:pluginssync Step 5b, 10.3 s in #12539's audit) spends its time in bash, not in git. Measured on a 91-install fixture where everymelodic-softwareuser record points at the marketplace clone's HEAD, so all 91 installs are compared:readandmapfilebuiltins read one byte perread()call when they cannot buffer the input. On Linux that is a pipe. The 17,491-entrygit ls-treestream took 2,198,223read()calls from a pipe and 571 from a file, 0.199 s against 0.005 s. Thefind | sort -zandcheck-ignorestreams pay the same way.__CYGWIN__, bash reads one byte per call from every descriptor, regular files included: bash 5.2'sbuiltins/mapfile.defsetsunbuffered_read = 1there, andbuiltins/read.defsetsinput_is_pipe = 1. MSYS2's bash, and so Git Bash, is a Cygwin build: its PKGBUILD applies0001-bash-4.4-cygwin.patch. That__CYGWIN__is defined in that build is inferred, not checked. On that host the check still pays about one emulated syscall per byte it reads through a builtin. That is the main suspect for the 10.3 s, and this PR does not change it there.not-at-headinstalls cost almost nothing. Pass 1 settles them with onerev-parsefor the whole marketplace, before any tree, find or hash work.Fix
cache-content-check.shwrites itsls-tree,find | sort -zandcheck-ignoreoutput to one privatemktempfile, removed on exit, and runsmapfileon that file. This cuts the read calls on Linux and macOS.bump: patch.Verification
cache-content-check.test.sh: 28 cases, 0 failed, including the read-only and process-budget cases.scripts/check-affected.sh --testson the first commit: 13 passed, 2 failed. The failing cases are home-path and live-claudecases infleet-state.test.sh,reset-refresh.test.shandsync-run.test.sh. The first two fail the same way on an unchanged checkout on this host.sync-run.test.shstubscache-content-check.sh, and the other two do not call it, so this change cannot affect any of them. CI decides those.cmp), on the fixture and on this host's real state (--all --scope all).findandhash-object, which this change does not touch.read()calls across the whole process tree for one fixture run, Linux (strace -f -c): 4,510,439 before, 217,438 after.Remaining on #12541
awkprocess. Either one changes the script's path transport, so it belongs in its own change.timings.cache_content_checkin a sync digest before and after. This host cannot measure it.git hash-object --pathre-hash per raw hash mismatch: 54 on the fixture, all of them real differences in its 27 stale installs.readlink+hash-objectpair per symlink: 0 on the fixture, which has no symlinks.Related
🤖 Generated with Claude Code
https://claude.ai/code/session_01VcuponMacsFYBfNzLKb3ws