Skip to content

perf(coverage): read the tracking decision cache once per process - #1109

Merged
Chemaclass merged 1 commit into
mainfrom
perf/1104-cache-in-memory
Aug 13, 2026
Merged

Chemaclass merged 1 commit into
mainfrom
perf/1104-cache-in-memory

Conversation

@Chemaclass

Copy link
Copy Markdown
Member

🤔 Background

Related #1104

should_track consulted its on-disk decision cache with
$(grep "^${file}:" "$cache_file" | head -1) — three processes per lookup. The
in-memory caches die with each test subshell, so that ran 1427 times in one
run of one test file
, over 13 distinct files.

💡 Changes

  • The cache file is read once per process into memory; entries this process writes go to both copies, so it is never re-read
  • 2 ms → 0.064 ms per lookup; a --coverage run of one test file 4.4 s → 3.3 s, same hit count, sequential and parallel agreeing
  • The dirname fork in the parallel cache path goes too — it ran per call
  • Same shape perf(coverage): the string-scan caches cost 26ms per lookup at 121 files #1076 removed from the stats cache: a cache costing more than the computation it replaces

should_track keeps its decisions in a file and consulted it with

  cached_decision=$(grep "^${file}:" "$cache_file" | head -1)

three processes per lookup. The in-memory caches die with each test subshell,
so that ran 1427 times in a single run of one test file, over 13 distinct
files: 2ms per lookup against 0.064ms for an in-memory scan of the same
entries. The same shape #1076 removed from the stats cache -- a cache costing
more than the computation it replaces.

The file is read once per process now and entries this process writes are
appended to both copies, so it is never re-read. A worker that misses an entry
another worker appended afterwards recomputes it, which is the same decision
at a little cost.

4.4s to 3.3s for --coverage over src on one test file, same hit count,
sequential and parallel agreeing. The dirname fork in the parallel cache path
goes too: it ran per call.

Closes #1104
@Chemaclass Chemaclass added the enhancement New feature or request label Aug 13, 2026
@Chemaclass Chemaclass self-assigned this Aug 13, 2026
@Chemaclass
Chemaclass merged commit b2e2bca into main Aug 13, 2026
37 checks passed
@Chemaclass
Chemaclass deleted the perf/1104-cache-in-memory branch August 13, 2026 09:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant