Repository navigation
GPU: a list's small first scratch chunk may be a kept 4 MiB one; 512 MiB of spare chunks (follow-up to #1349) - #1367
Merged
Conversation
…MiB of spare chunks The spares stood at their bound of 128 MiB the whole run, all of them 4 MiB ones: a list's small first chunk (256 KiB) was made new every time, and what came back past the bound was freed. On an RTX 5080 (Jason's balcony, Series S) that was some 35 chunks of 256 KiB (about 1 ms each to free) and 12 of 4 MiB (2-2.5 ms each) a frame, on whichever thread dropped them. - A small first chunk is a kept 4 MiB one when no small one is kept (VICTORY_SCRATCH_ANY_SIZE, on; =0: only one of its own size). - 512 MiB of spares are kept (VICTORY_SCRATCH_SPARE_MB; it was 128). Measured on an older base with this fork's relay and the CGBJ patches, drops on a thread of their own: 52-56 ms a frame instead of 63-84, resources destroyed by dropping 0 a frame instead of 30-52, scratch memory about 395 MB instead of 270. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Follow-up to #1349. That issue was about where retired objects get dropped. This PR is about why there were so many expensive ones to drop in the first place.
What
Two changes to the shared list scratch chunks (
take_chunk/give_chunksinhost.rs):take_chunknow returns the chunk with its real size, so the list uses the whole 4 MiB and gives it back as 4 MiB. Turn it off withVICTORY_SCRATCH_ANY_SIZE=0.VICTORY_SCRATCH_SPARE_MB.Why
I traced the slow drops from #1349 by kind. Almost all of the expensive ones were scratch chunks: committed upload buffers whose last reference a descriptor slot held. On the balcony (Series S, RTX 5080) that was per frame:
The spares sat at the 128 MiB bound for the whole run, and all of them were 4 MiB ones.
Spare::takeonly returns an exact size match, so every small first chunk was made new. Meanwhile, chunks coming back past the bound were freed. The lists hold about 140 MB of chunks at once there, so 128 MiB was just short.Measured
Measured on my build, not on this main. It is an older base with this fork's relay code (
VICTORY_RELAY=2) plus the CGBJ patches,--console series-s, diag profile. RTX 5080, 7800X3D, 32 GB. Jason's balcony after the first mission, same camera every run, around world+696. Drops already on their own thread (likeVICTORY_REAPER=1).VICTORY_SCRATCH_ANY_SIZE=0 VICTORY_SCRATCH_SPARE_MB=128), 2 runsThe first run after a rebuild or a restart was 58-60 ms with the change. Scratch memory went from about 270 MB to about 395 MB. The pictures look the same and there were no device removals.
On this main the code is the same as on my base (exact-size
take,SPARE_MOST= 128 MiB), so I ported it as is. I haven't measured it on this main yet. It would be good if someone could do an A/B with the two variables above.Notes
host.rsis already over the 512 KiB asset policy limit on main, so the policy check will fail here until Move host.rs's and lower.rs's test modules to their own files, under the asset policy's 512 KiB limit #1357 or Policy: allow up to 2 MiB for Rust source files under asset policy #1361 is in.cargo check -p victory-gpupasses. I didn't run the full test suite.