Skip to content

Reuse the effective disc reader during resident pack preparation - #771

Merged
mstan merged 3 commits into
RetroPortingToolKit:masterfrom
michaelm-afk:pr/seamless-scoped-disc-reader
Oct 27, 2026
Merged

mstan merged 3 commits into
RetroPortingToolKit:masterfrom
michaelm-afk:pr/seamless-scoped-disc-reader

Conversation

@michaelm-afk

@michaelm-afk michaelm-afk commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Reuse the effective disc reader during resident pack preparation

Resident preparation verifies every catalog entry even when its pack is warm.
Each extent/read service previously reopened and reparsed the same CUE/BIN.
For EU1's 2,257 entries this is costly on a network share.

Add a thread-local RAII reader scope around psx_resident_prepare. The existing
three host file services reuse that reader only inside the preparation scope.
Nested scopes share it; mount changes invalidate it, failed opens are not cached,
and normal/exception exits release it. Outside the scope fresh-open behavior is
unchanged. Current effective sector overlays and ISO records are still read.
No disc identity, source hash, pack integrity or fail-closed fallback is skipped.

Prior controlled EU1 timings (single passes, not guaranteed): warm NAS preparation
21.514 s -> 0.208 s; warm local host preparation 1.464 s -> 0.224 s. Cold NAS
payload preparation remains about 44 s. The cold packs were byte-identical
(150,907,348 bytes); 2,257 source / 816 GAM checks and corruption/fallback tests
passed. The owner subsequently confirmed the EU1 optimization in ordinary use.

The transferred official-source scoped-reader regression passes: outside-scope
fresh reader, reuse/nesting, missing or changed mounts, exception cleanup.
The CMake target includes the official host-path header directory. The shared
path serves USA/EU1/EU2/Japan; practical performance acceptance is EU1, not all
regions or a full campaign. All four updated official-source Windows candidates built and passed original-disc verification, bounded relocated boot smokes and package privacy checks; no new all-region gameplay acceptance is claimed.
No deferred asset work or guest loader/timing change is introduced.

Independent of the audio and renderer PRs. No title or recomp-ui patch needed.

@mstan mstan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed preparation-local thread-local/nested reader reuse, changed-mount/open-failure handling, fresh effective-sector reads and integrity boundaries. The actual resident/runtime/read-session suites pass in the combined Release gate. Retained author warm-local/NAS measurements are distinguished from unchanged cold latency.

Pushed 15e0f20 with the exact b66b37b lease to clean the generated test fixture after all reader handles close. The strengthened existing test passes on Windows with successful removal. This changes only the test; production code is identical to the qualified combined bb0d6de build. Final integration branch review/issues248-prs703-20261026 at 24d80d7 includes that cleanup. Ready from this review.

@mstan
mstan merged commit a38bf78 into RetroPortingToolKit:master Oct 27, 2026
1 check passed
tetrisgm pushed a commit to tetrisgm/psxrecomp that referenced this pull request Oct 27, 2026
…ess-scoped-disc-reader

Reuse the effective disc reader during resident pack preparation
@michaelm-afk
michaelm-afk deleted the pr/seamless-scoped-disc-reader branch October 27, 2026 06:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants