perf(blocks): stop rescanning every transcript when no block is found - #569
Merged
sirmalloc merged 3 commits intoSep 2, 2026
Merged
Conversation
getCachedBlockMetrics wrote the cache only when a scan produced metrics. getBlockMetrics returns null whenever the newest usage entry is older than the session duration, so nothing was written and the next repaint repeated the whole scan: a glob over every transcript under the config directory, a stat on each, then a full read of everything inside the lookback window. Measured against a corpus of 18,837 transcripts totalling 16.2 GiB, one such repaint costs 16,186 ms and 1,885 MiB read, and returns null having cached nothing. Replaying seven days of real history at fifteen minute intervals, 115 of 673 instants land in that state, so roughly one repaint in six paid it. Record the empty answer with a short expiry and return early while it stands. A new block is reported at most one interval late, and the widgets built on this render whole minutes, so a minute of staleness is not visible. A positive result still takes precedence, and a record naming a different config directory is still ignored. The helpers stay module-private; the public surface does not change.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
getCachedBlockMetricswrites the cache only when a scan produces metrics.getBlockMetrics()returnsnull whenever the newest usage entry is older than the session duration, so nothing is written and the
next repaint repeats the whole scan: a glob over every
*.jsonlunder the config dir, astatSynconeach, then full reads of everything in the lookback window.
Corpus of 18,837 transcripts, 16.2 GiB, instant shifted so no block is active:
When a block is found: 19,371 ms, then 25 ms, then 0 ms. The positive path already had this; the null
path did not. Replaying 7 days of history at 15-minute intervals, 115 of 673 instants land in it.
This records the empty answer with a 60 s expiry. A new block is reported at most that late, and these
widgets render whole minutes. A positive block still wins; a record naming another config dir is still
ignored. Both helpers are module-private, so the public surface is unchanged.
Five tests. Suppression is asserted by the stored instant not moving, not by spying. Mutation-verified:
never writing the record, never reading it, ignoring expiry, ignoring config dir, letting it beat a live
block, expiry of zero, expiry of a year. All seven fail the suite.
Separate defect from #568, which fixes one transcript being read five times in a single render.
This one is about a scan result that is never cached, so it repeats every repaint. Either can land
alone; they share no file.