feat(mods): the Mods tab says which archives are served as one, and a damaged cached archive is made again #3173
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/mods
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!3173
Loading…
Reference in a new issue
No description provided.
Delete branch "snaildev99/Longshot:mods/archive-parity"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
When two mods change the same archive (a pack, a layout archive, a language's texts),
mainalready serves onearchive with each mod's changes in it, and the mod lower in the list wins only the files inside it that both changed.
But the player wasn't told: the counts stayed in the merge step. And the merged archive kept in the cache was served
again whenever its record parsed and the file existed, so a damaged or replaced cache file was served as it was.
With this change:
them a mod lower in the list takes. It counts what the layers serve, path by path: when hot reload holds a path back
to the next start, the tab keeps the count of the file still served there.
made again (the record's version string moves on, so older entries are made again once). The hash reads the file a
MiB at a time, so a cache hit holds no copy of the archive, and an archive near the 256 MiB limit, whose zstd frame
on disk is a few KB larger than that, is still read back and recorded.
?in its place, at most 160 bytes), the samein the log and the record.
This is the rest of #1089 (the size table entries of a pack's files are the pack PR, #3172).
Read first:
game/crates/content/src/merge.rs(ArchiveRecord,Step::cached_file,Rom::host_hash,clash_name), thengame/crates/api/src/loader/mod.rs(push_archive, the tab's text) andgame/crates/api/src/loader/hot.rs(Inputs::rebuild: a held path's archive).Testing
Tested: Windows 11 Pro, RTX 3090, NVIDIA 610.88, in the game, built by
longshot-builder play --profilewiththis PR and the other mod compatibility ports merged, then the same profile on
main. Two test mods made on this PCfrom the game's own
Pack/Actor/Land_LonLon_WheelTrack_A_05.pack.zs(kept local): each grows a different file insidethe pack.
Pack/Actor/Land_LonLon_WheelTrack_A_05.pack.zs: 2 mods' copies served as one archive, each file inside it from the mod that changed it (1 of local/archive-test-a, 1 of local/archive-test-b); 2 files in it, made now, andas made beforeat the next start.mainthe samepages say nothing of it (screenshots below).
made now(1 written now) andthe file is written again. On
mainthe damaged file is served (as made before).Game-free: the seven tests below. The sentence for files a lower mod takes is the game-free test's alone (the two test
mods change different files). Three came with the review's fixes, on this PR rebased onto
main@3a0f7d8f7:an_archive_whose_frame_is_over_the_read_limit_is_served_and_found_made(content: an archive written as the hostwrites it, a zstd frame of raw blocks, to a host whose whole read takes the archive's size but not the frame's; it is
recorded, served, and found made at the next start) and
the_mods_tab_counts_the_archive_served_not_one_held_back(api: a second mod's copy of a pack added while the game runs, held back to the next start, then served) each failed
on the rebased code before its fix, for the review's reason (the lowest mod's whole copy served; both pages saying
"served as one" while the held path still served one mod's copy), pass with it, and fail again with the fix's key line
undone.
the_host_hashes_a_file_a_piece_at_a_time(content) checks the host's piece-at-a-time hash of a real fileagainst the hash of its whole bytes.
cargo test -p content@d5ba0289f: 278 passed;cargo test -p api: 593 passed, 1failed (
watch::tests::a_walked_reshade_folder_counts_a_change_once_two_walks_agree, inwatch.rs, which this PRdoesn't touch; it fails the same way on
main@3a0f7d8f7).After the rebase and the review's fixes, the same profile again, built with this PR @
d5ba0289fand the other portsmerged (929bf025a): the log says
2 mods' copies served as one archive ... made now, each mod's page says "1 of itsarchives is served as one with other mods' copies." (screenshot in the comments), and with one byte of the cached
archive flipped, the next start's fast check finds the game folder up to date and the archive is
made now. Astart without the damage says
as made before.mise run test, run locally while CI's run waits for approval (Windows 11,tests/run_all.py --strict, 12 checks atonce), here @
d5ba0289fand onmain@3a0f7d8f7: 841 passed, 18 failed, 52 skipped here; 845 passed, 14 failed, 52skipped on
main. 14 of the 18 also fail onmain: test_dlssg, test_fsr4_tune, test_lifter, test_no_game_title,test_no_map_reload, test_present_acquire_ahead, test_present_geometry_trace, test_present_held_image,
test_present_image_free, test_program_cache_store_record, test_rt_pin, test_sync_watch_event, test_turf_budget,
test_ui_renderer. The other four (test_dev_update, test_invalidate_vcore, test_prepare_stall, test_present_probe)
hit their timeouts under that load and pass here run alone (
--exact, 4 passed); this PR touches none of thesources they cut.
Still to test:
main: the merge step'stime and the cache's size (measurement, the review's L3)
Measurements
Verdict: It works: a damaged cached archive is made again, and the Mods tab names a shared archive, in the game
and in the tests. A start that serves the cached archive now reads and hashes the made file: 0.13 ms for this
132 KB archive and 24 ms for a 24 MiB one (the game's largest pack), the hash timed alone in a release build.
Setup:
cargo test -p contentand-p apion Windows 11,main's code with the new tests on the before side; thenthe test profile above in the game, Windows 11 Pro, RTX 3090, the same profile copied for
main. The game's Aftercolumn is the build with the other mod compatibility ports merged (72d64e92f), which holds this PR's commit. These
rows were measured before the rebase; the game's results are the same on this head (Tested).
f577a1aea8bbac75d3a_damaged_cached_archive_is_made_againa_clash_whose_name_has_a_control_character_is_one_log_linea_shared_file_that_is_no_archive_is_not_read_wholethe_mods_tab_says_an_archive_is_served_as_onecargo test -p contentd5ba0289f, with the review's two content testsas made before(the damaged file served)made now,1 written nowThe merge step's gap in the game (about 11 ms) is larger than what this PR adds to it: the cached path differs from
main's only in reading the made file (0.14 ms for 132 KB, read cold from a new process) and hashing it (0.13 ms), andthe step's timer and loop are
main's. The game's build holds seven other ports, so the gap is not this PR's alone; itis not broken down further.
The review's fixes, game-free (their tests test this PR's own code, so the before side is this PR rebased onto
main@
3a0f7d8f7without them, notmain):d5ba0289fan_archive_whose_frame_is_over_the_read_limit_is_served_and_found_madethe_mods_tab_counts_the_archive_served_not_one_held_backRisks
updating; the old entries go with the cache's ~1 GiB sweep.
archives (24 ms for the game's largest pack), on every start with mods that share an archive. It reads a MiB at a
time, so it holds no copy of the archive.
Checklist
Ready for review
main; the title is a Conventional Commit.mise run testpasses (any failure that also fails onmainis named). (run locally, Testing names them; CI's run waits for approval)main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
tests/that reads changed source is updated, not weakened. (tests/test_parity_gates.pyreadsloader/mod.rs's log lines, which this keeps: it passes unchanged in the suite)mainand here, for a change that shows on screen. (in the comments)Assisted-by:/Co-Authored-By:trailers.Ready to merge
main, measured again or a comment says why the numbers still hold.🤖 Generated with Claude Code
Tested in game: Windows 11 Pro, RTX 3090, NVIDIA 610.88: built by longshot-builder play --profile with this PR and the other mod compatibility ports merged, then the same profile on main; adult Link in Kakariko. Two local test mods share one actor pack: the log serves it as one archive ('made now', then 'as made before'), and each mod's Mods tab page says '1 of its archives is served as one with other mods' copies.' (main says nothing). One byte of the cached archive flipped: the next start makes it again ('made now', '1 written now'); main serves the damaged file ('as made before').
Screenshots: Archive test A's page in the Mods tab, the same test profile on both sides (Windows 11, RTX 3090).
Before, main @

f577a1aea: the state says nothing of the archive the two test mods share.After, this PR (the build with the other mod compatibility ports merged, 72d64e92f): "1 of its archives is served as one with other mods' copies."

mise run test, run locally while CI's run waits for approval: 824 passed, 21 failed, 51 skipped here @
8bbac75d3; 16 of the 21 also fail on main @f577a1aea(named in Testing), the other five timed out under load and pass here run alone (--exact): the two audio checks beside two other suites, the three renderer fixtures with nothing else running. test_parity_gates, which reads loader/mod.rs, passes unchanged. Box ticked.WIP: feat(mods): the Mods tab says which archives are served as one, and a damaged cached archive is made againto feat(mods): the Mods tab says which archives are served as one, and a damaged cached archive is made againRecommendation: Request changes. A valid large merged archive can be discarded after it is written, causing the game to serve only the lowest mod’s copy. The Mods tab can also report a hot-reload result that was held back rather than served.
The change reports shared archives in the Mods tab and verifies cached archives before reuse. The Windows run shows both features working for a small pack; verification adds a full read and hash on cache hits.
Blocking (2): must change before merging.
game/crates/content/src/merge.rs:811: The read-back applies the decoded archive limit to the larger on-disk zstd frame. (more on the line) Do: Hash the written frame with a bound that includes zstd framing overhead, or stream the hash without loading the entire frame; add a boundary test using the real framing semantics.@​fixor@​rebasetry first). (for the author)Should fix (1): not blocking, but worth doing before merging.
game/crates/api/src/loader/mod.rs:1224: The counts describe the rebuilt table before hot reload decides which paths can actually be published. (more on the line) Do: Retain per-path merge counts and publish counts corresponding to the paths actually kept or replaced by hot reload.Testing before merging (1) (runs on the systems it can change; it doesn't hold the recommendation)
game/crates/content/src/merge.rs:707: The startup cost of verifying all cached shared archives has not been isolated on the PR’s own build or checked on Linux. (more on the line) Do: Compare interleaved cold and warm starts on base and this head with a representative multi-archive profile, including Linux, and report total merge time and cache size. (@fixdoes its part first: Stream the hash in bounded chunks to avoid allocating a full archive on each cache hit.)@fixcan do L1, L2 and L3.Checks: Still running: 11 checks.
More: does it help, other systems, switches, what was read
Does it help: Yes for the demonstrated cases: on Windows, a flipped cache byte caused a rebuild instead of reuse, and both test mods displayed the shared-archive note. The isolated cost was reported as 0.13 ms for 132 KB and 24 ms for 24 MiB; the measured 11 ms merge-step gap includes other changes and cannot isolate this PR.
Other systems: The cache and loader run on Windows and Linux and during hot reload. The reported game run covers Windows with NVIDIA; Linux behavior and startup cost with a larger set of shared archives remain unmeasured. No renderer, save, audio, or input code changes are apparent.
Switches: None.
Reviewed:
8bbac75d30againstf577a1aeab: Read the repository rules, PR template, standards, commit, changed diffs, and the relevant merge, SARC, loader, RomFS and hot-reload paths. The large loader and test files and the long reference documents were skimmed rather than read completely; no generated files or translations changed. Tooling’s adjacent AGENTS.md was unavailable.; nothing run (a code review).Checked and fine:
Testing: No code or tests were run for this review. The author reports a Windows game run and game-free tests; CI is still running.
Overlaps and merge order: The description identifies #3172 as the related pack size-table work; merge order was not established.
Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, as snaildev99 took it out of WIP. Nothing was run; a maintainer decides.
@ -1205,0 +1221,4 @@for (layer, count) in &m.counts {let Some(id) = names.get(*layer) else { continue };if let Some(row) = self.rows.iter_mut().find(|r| r.id == *id) {row.archives_merged = count.archives_merged;L2 (should fix): The counts describe the rebuilt table before hot reload decides which paths can actually be published.
When: When an edited shared archive needs a larger resource-size entry, hot_rebuild retains the previous path with Builder::keep, but these new counts are still published to the Mods tab. A mod can consequently be told its archive is merged, or that a file was taken, when the currently served archive has the old result.
Do: Retain per-path merge counts and publish counts corresponding to the paths actually kept or replaced by hot reload.
@ -643,0 +704,4 @@_ => return false,}self.rom.host(path, false).is_some_and(|raw| mix(SEED, &raw) == r.file_hash)}L3 (should fix): The startup cost of verifying all cached shared archives has not been isolated on the PR’s own build or checked on Linux.
When: Players with several large shared archives read and hash each one on every cached start; the reported in-game comparison includes seven other ports, so it cannot show this change’s total startup cost.
Do: Compare interleaved cold and warm starts on base and this head with a representative multi-archive profile, including Linux, and report total merge time and cache size.
@ -748,0 +808,4 @@let Some(raw) = self.rom.host(&path, false) else {host_sys::log::warn(&whole);return Archive::Kept;};L1 (blocking): The read-back applies the decoded archive limit to the larger on-disk zstd frame.
When: A merged archive near the permitted 256 MiB limit is written as raw zstd blocks. Frame headers make the disk file larger than PART_MAX, so HostRom::host rejects the read-back and this returns Kept, serving only the lowest mod’s whole archive even though the merge succeeded.
Do: Hash the written frame with a bound that includes zstd framing overhead, or stream the hash without loading the entire frame; add a boundary test using the real framing semantics.
8bbac75d30d5ba0289f1Rebased onto main @
3a0f7d8f7for the base conflict; here @d5ba0289f. Tested (the game again on this head),mise run test(against main @3a0f7d8f7: four timeouts under load, each passing alone; the rest also fail on main) and Measurements are updated. Answers to the review below.L1 (the read-back applies the archive limit to the larger zstd frame): fixed in
d5ba0289f. The host writes a madearchive as a frame of raw blocks, 10 bytes of head and 3 before each 128 KB block, so an archive of 256 MiB is about
6 KB larger on disk, and
HostRom::hostrefused to read it back whole. The made file is now hashed a piece at a time:Rom::host_hashgives its size and FNV-1a hash, andHostRom's reads 1 MiB at a time with no limit of a whole read.Both the read-back after a write and
Step::cached_fileat a later start use it. The testan_archive_whose_frame_is_over_the_read_limit_is_served_and_found_madewrites the archive in that framing to a hostwhose whole read takes the archive's size and not the frame's. Before the fix, it served the lowest mod's whole copy;
now the archive is recorded, served, and found made at the next start with nothing written.
the_host_hashes_a_file_a_piece_at_a_timechecks the host's reader against the hash of the whole bytes, across thepieces' edges, on a real file.
L2 (the Mods tab counts a rebuild's archives before hot reload decides what is published): fixed in
d5ba0289f. It stillheld after the rebase: #3151 moved the rebuild off the game's thread but kept
Builder::keepfor a path held back.The loader now keeps the archives served as one path by path (
Merged::archives, by the mods' ids), and the tab countsfrom them. A rebuild takes the new build's entry for each path it serves anew, the previous one for a path it keeps,
and none for a path that goes back to the game's own file. A file of the held layers that leaves takes its entry with
it.
the_mods_tab_counts_the_archive_served_not_one_held_backadds a second mod's copy of a pack while the game runs,with the size table unchecked. Before the fix, both mods' pages said the archive was served as one while the first
mod's whole copy was still served; now they say nothing of it until the archive is served, and then both say so.
L3 (the startup cost of checking cached archives): the code part is done in
d5ba0289fwith L1. A cache hit no longerreads the whole archive into memory: it holds 1 MiB at a time while it hashes. The measurement (interleaved cold and
warm starts on
mainand this head with several shared archives, Windows and Linux, the merge step's time and thecache's size) is still to run.
L4 (conflicts with
main): rebased ontomain@3a0f7d8f7. The rebuild while the game runs is #3151's now: thelayers are built off the game's thread from sources taken on it. So the tab's counts come back with the rebuild's
outcome and are taken in on the game's thread.
docs/user/using-mods.mdkeeps both new paragraphs: archives served asone, then mods that load last.
In the game on this head (929bf025a, with the other ports merged): Archive test B's page.
Still to test now lists the measurement the review asked for, which the answers above say is still to run.
@review
Recommendation: Approve. The code is ready: only testing is left. The archive read-back and hot-reload count fixes address the reported cases. Startup cost with several shared archives still needs measurement on Windows and Linux. Recommend approval; not approved on the forge.
The Mods tab reports shared archives and lost member changes, and damaged cached archives are rebuilt. Cache hits now require a file read and hash; the fix bounds hashing memory to 1 MiB.
Testing before merging (1) (runs on the systems it can change; it doesn't hold the recommendation)
game/crates/content/src/merge.rs:707: The startup cost of verifying several cached shared archives remains unmeasured on the PR's own build and on Linux. When: A player starts with several shared archives; every cache hit reads and hashes its made file, but the combined startup cost is unknown. Do: Measure interleaved cold and warm starts against main on Windows and Linux, recording merge-step time and cache size. (@fixdoes its part first: Stream the hash in bounded chunks to avoid allocating a full archive on each cache hit.)@fixcan do L3.Since the last review (on
8bbac75d30)Resolved: L1 (The read-back applies the decoded archive limit to the larger on-disk zstd frame.); L2 (The counts describe the rebuilt table before hot reload decides which paths can actually b…); L4 (It conflicts with its base branch: bring it up to date (
@​fixor@​rebasetry first).)Still open: L3 (The startup cost of verifying several cached shared archives remains unmeasured on the PR'…)
Checks: Still running: 11 checks.
More: does it help, other systems, switches, what was read
Does it help: Yes for the reported behavior: the author reports that a damaged cache was rebuilt and both mod pages showed the shared archive in game on Windows. The author measured hashing alone at 0.13 ms for 132 KB and 24 ms for 24 MiB; the combined startup cost remains unisolated.
Other systems: The cache and loader paths run on Windows and Linux. The reported in-game run covers Windows; Linux behavior and startup cost with several shared archives remain unmeasured.
Switches: None.
Reviewed:
d5ba0289f1against3a0f7d8f7f: Read AGENTS.md, CONTRIBUTING.md, the pull request template, the supplied review history and the changed loader and merge excerpts. The full changed files, remaining diff, referenced standards and dependent code were not read in full; docs/review-checklist.md is absent.; nothing run (a code review).Checked and fine:
Testing: No code or tests were run during this review. The author reports 278 content tests passing and 593 API tests passing with one failure also present on main; CI remains running.
Overlaps and merge order: Not checked.
Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
@rebase
I rebased this pull request onto
main(e813a37f63): the new head is3e947e8546.Conflicts resolved
Nothing was built or run: read the resolution before merging.
Automated rebase by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
d5ba0289f13e947e8546Recommendation: Approve. The code is ready: only testing is left. The cache check and Mods tab behavior have reported in-game and game-free coverage, but the startup cost with several shared archives is still unmeasured on the PR’s own build and on Linux. Recommend approval; not approved on the forge.
The Mods tab reports shared archives and files taken by lower mods, and damaged cached archives are rebuilt. Cache hits now read and hash each made archive, adding startup work in exchange for detecting damage.
Testing before merging (1) (runs on the systems it can change; it doesn't hold the recommendation)
game/crates/content/src/merge.rs:707: The startup cost of verifying several cached shared archives remains unmeasured on the PR's own build and on Linux. When: A player starts with several shared archives; every cache hit reads and hashes its made file, but the combined startup cost is unknown. Do: Measure interleaved cold and warm starts against main on Windows and Linux, recording merge-step time and cache size. (@fixdoes its part first: Stream the hash in bounded chunks to avoid allocating a full archive on each cache hit.)@fixcan do L3.Since the last review (on
d5ba0289f1)Still open: L3 (The startup cost of verifying several cached shared archives remains unmeasured on the PR'…)
Checks: they run again on this head; a failure shows on the pull request.
More: does it help, other systems, switches, what was read
Does it help: Yes for the reported fix: on Windows, a flipped cache byte caused the archive to be rebuilt, while main served it unchanged. The reported hash time was 0.13 ms for 132 KB and 24 ms for 24 MiB; the total startup cost with several archives remains unproven.
Other systems: The cache check runs on Windows and Linux; Linux startup cost remains unmeasured. Hot reload retains counts for held paths, with a reported game-free test; GPU behavior is not directly changed.
Switches: None.
Reviewed:
3e947e8546againste813a37f63: Read AGENTS.md, CONTRIBUTING.md, the pull request template, the loader diff and surrounding changed line, the cache hash and read-back paths, and the documentation and hot-reload diffs. The remaining changed code and tests were not read in full; recorded runs were skimmed. docs/review-checklist.md and the adjacent Tooling AGENTS.md were absent.; nothing run (a code review).Checked and fine:
Testing: No commands that build or run the project were executed. The author reports Windows in-game checks and game-free tests; CI has not run on this head.
Overlaps and merge order: The description identifies #3172 as the related pack size-table work; merge order was not established.
Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, after its rebase. Nothing was run; a maintainer decides.