dstorage: size the worker pool to physical cores (copy-back 5.7 -> 2.4-3.5 ms/MB on an 8c/16t machine) #1044
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/fxceless--victory-fork!1044
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1044"
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?
@Key-rs on GitHub · 2026-11-25 17:18 UTC · original
Key-rs:perf/dstorage-workers→main· +86 −1 · 2 files · 2 commits · openThe storage pool starts one worker per logical processor. On a machine with SMT that is twice the physical cores, and those workers compete with the submitting thread, the copies and the title's own threads for cores that do not exist. Size it to physical cores instead, with
VICTORY_DSTORAGE_WORKERSto set it outright.What it measured here
Ryzen 7 8845H (8 cores, 16 threads), RTX 4060 Laptop 8 GB,
0b0074e, same package, same switches (VICTORY_RELAY=2 VICTORY_LATE_WAIT=3 VICTORY_WIDE_BACK=1 VICTORY_CARD_BUFFERS_MIN_MB=1 VICTORY_CARD_BUFFERS_MB=1024), same scripted input:The per-megabyte cost of the copy-back roughly halves, which is the part of this that is not scene noise (the frame numbers moved with the scene each sample; the copy-back figure is per megabyte and moved consistently).
What changed
worker_count():VICTORY_DSTORAGE_WORKERSif set (1–64), otherwise the physical core count, with the old value as a fallback when the system will not say.physical_cores():GetLogicalProcessorInformationEx(RelationProcessorCore), one record per core. Adds theWin32_System_SystemInformationfeature tovictory-hle; no new dependency.Why physical rather than logical
The pool exists to read, inflate and unpack in parallel, and it is bounded by the staging buffer anyway. SMT twins add little to that kind of throughput, while the thread that submits and copies is the one that stalls when too many workers are resident —
slow host submission ms=355 lists=43on the same runs. If a machine reports one core (or the query fails) the old behaviour is kept, so this cannot reduce the pool below what a machine without SMT had before.Two things I did not do, in case you would rather they went the other way:
VICTORY_DISK_CORESalready covers leaving the fast cores alone, and I did not want to add a second mechanism for the same thing.shadow.rs,available_parallelism()/4) or the pipeline workers. If the same argument holds there, it is a separate change with its own measurement.@UwUCammie on GitHub · 2026-11-25 17:48 UTC · original
Tested this on Linux + Wine 11.22 + RX 7900 XT (8c/16t CPU,
RELAY=2, 480 s run into the cell scene).GetLogicalProcessorInformationExpicked updstorage: workers=8cleanly under Wine (instead of 16 logical threads) and the whole 480 s run ran with no hangs, texture streaming issues, or crashes.@Key-rs on GitHub · 2026-11-25 17:54 UTC · original
That is the part of this I could not test myself — thank you. I have Windows only, so I had no idea whether GetLogicalProcessorInformationEx(RelationProcessorCore) would answer at all under Wine; if it had not, the fallback (vailable_parallelism() / 2) would have quietly given the same 8 on an 8c/16t machine and the change would have looked fine while doing nothing on Linux. Seeing it report the physical cores there, and 480 s of cell scene with no streaming regressions, is a better test than the one in the description.
For the record on my side: 8c/16t Zen 4, RTX 4060 Laptop, copying back went from 5.7 ms/MB (16 workers) to 2.4-3.5 ms/MB (8), and the same run with VICTORY_DSTORAGE_WORKERS=16 puts it back, which is how I convinced myself the change and not the scene was doing it.
If you still have that Wine box, the one thing worth a look is a machine whose cores the query reports oddly (containers or VMs that claim many logical processors and few cores): VICTORY_DSTORAGE_WORKERS is the way out, and I would rather hear about it before the default is trusted on Linux than after.
@SkillIssueXO on GitHub · 2026-11-25 21:38 UTC · original
I checked the topology walk at
0bba762on Windows.SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EXstarts withRelationship, followed bySize. The first two DWORDs returned forRelationProcessorCorehere are0and48. The current loop reads that0as the record length and exits, soworkers=8on an 8c/16t machine can come from the fallback.Reading
Sizeatoffset_of!(SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX, Size)and bounding the walk by the returned byte length counted 8 physical cores from the API (384 bytes). I also checked that the corrected walk rejects a truncated record. Windows SDK record layout@Key-rs on GitHub · 2026-11-26 01:38 UTC · original
You are right, and thank you — that is a bug in the change, not a stylistic point.
SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX starts with Relationship (which is RelationProcessorCore == 0 for every record this walk asks for) and only then Size, so reading the first dword as the length always got 0, the loop broke on size < 8, physical_cores() returned None, and workers=8 came from the fallback vailable_parallelism() / 2. On an 8c/16t machine the two paths agree, which is exactly why it looked correct — your ␀ and 48 pair is the giveaway I should have caught.
Fixed in
4d1bf6b: the length is read at offset_of!(SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX, Size), the walk is still bounded by the byte length the API returned, and it now logs which of the two paths produced the number, so the next reader can tell an API answer from a fallback without a debugger:dstorage: physical cores, from the system cores=8 logical=16 dstorage: workers workers=8On this machine (Ryzen 7 8845H, 8c/16t) the API path reports 8 cores, matching your 384-byte walk.
Two things worth saying plainly:
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.