Repository navigation
perf: decouple preloader read-ahead depth from thread count - #27
Open
brandonocasey wants to merge 3 commits into
Open
brandonocasey wants to merge 3 commits into
brandonocasey wants to merge 3 commits into
Conversation
brandonocasey
force-pushed
the
perf/preloader-read-ahead
branch
from
July 22, 2026 22:36
b56fe1e to
e77f73e
Compare
brandonocasey
added a commit
to rom-weaver/rom-weaver
that referenced
this pull request
Jul 22, 2026
The read-ahead window was hardcoded to num_threads sector groups (8 MiB at the browser default of 4), so one OPFS latency spike in a dense disc region froze RVZ extract progress for the spike duration while preloader threads sat 93-98% idle and the LRU cache ~94% empty. Floor the window at 16 groups (~32 MiB) independent of thread count and size the cache to the window plus a reuse tail so prefetched groups survive until consumed. Mirrors upstream encounter/nod#27.
encounter
reviewed
Sep 16, 2026
|
|
||
| /// Minimum number of sector groups to request ahead of the consumer. 16 groups is ~32 MiB, | ||
| /// enough to ride out I/O latency spikes without stalling. More threads still deepen the | ||
| /// window; this floor only matters when the thread count is low. |
Owner
There was a problem hiding this comment.
Would you mind dropping or rewriting this comment?
|
|
||
| impl PreloaderCache { | ||
| /// Size the cache to fit the read-ahead window plus some reuse room, so prefetched groups | ||
| /// aren't evicted before they're used. Keeps at least the old fixed capacity of 64. |
Contributor
Author
|
all resolved |
The read-ahead window was hardcoded to num_threads sector groups (4 groups = 8 MiB at the default), so a single I/O latency spike in a dense disc region stalled the consumer for the full spike duration while preloader threads sat 93-98% idle and the LRU cache sat ~94% empty. Give the window a 16-group (~32 MiB) floor independent of thread count and size the cache to hold the full window plus a reuse tail so prefetched groups are not evicted before use. More threads still deepen the window and add I/O concurrency; the floor only matters when the thread count resolves low.
brandonocasey
force-pushed
the
perf/preloader-read-ahead
branch
from
September 21, 2026 20:13
7c74262 to
87a2af6
Compare
mq1
added a commit
to mq1/TinyWiiBackupManager
that referenced
this pull request
Sep 27, 2026
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.
While digging into ~1s progress stalls during RVZ extraction, I noticed the preloader stats in the stall window showed
io: 98.56%, req: 30.6ms, util: 51%while every other window sat around 2% utilization. The threads were mostly idle and the LRU cache was ~94% empty, but the consumer was still blocked on a slow read. The look-ahead inPreloader::fetchonly requestsnum_threadsgroups ahead (8 MiB at 4 threads), which is not enough to ride out an I/O latency spike in a dense region of the disc.With preloading enabled, this gives read-ahead a floor of 16 groups (~32 MiB) and sizes the cache to fit the window plus some reuse room, so prefetched groups do not get evicted before use. More threads still deepen the window like before. With
preloader_threads = 0, preloading stays disabled and reads use the existing synchronous path instead of queuing work with no workers. At four threads, the minimum window changes from 8 MiB to ~32 MiB.