Repository navigation
Conversation
files[index::count] balanced nothing. Shaders differ in size by two orders of magnitude, so a round-robin split can
hand one shard most of the work while every other process waits for it, and the stage is as slow as its heaviest
shard.
shard_bucket() sorts by file size (largest first) and gives each file to the lightest bucket so far, then a shard
takes its own bucket. Every shard computes the same partition from the same directory listing, so the processes still
do not talk to each other, and each bucket is handed out in name order.
Measured on a synthetic corpus shaped like the real one (96 shaders of 200 instructions, 16 of 2,000, 6 of 12,000;
largest 10% of the total; per-file time measured, then makespan over the buckets):
shards round-robin shard_bucket gain
2 2.15s 2.15s 1.00x
4 1.28s 1.09s 1.17x
8 0.65s 0.55s 1.18x
16 0.53s 0.42s 1.26x
The corpus is synthetic: what the real skew is has to be measured with game data, which is why the change keeps the
interface (--shard i/n) and the fallback (a file whose size cannot be read is scheduled, with weight 0) intact.
tests/test_rdna2spirv_shard.py checks the partition (disjoint, complete, deterministic, name order within a bucket),
that a skewed listing beats round-robin at every shard count, and that an unreadable file is not dropped.
|
Code read + CPU run of 30ade56 on Windows 11, Python 3.11.9: LGTM.
AI-assisted (Claude Code). |
|
Tested 30ade56 on Windows 11, Python 3.12.10 (CPU only): tests pass, and a measurement over my own 1.0.2.1 corpus (counts only) says the gain there is smaller than on the synthetic corpus in the docstring. Tests
Byte load per shard on the real listings (26,503
The largest listing is 0.20% of the total (143x the median), not 11%, so round-robin over the name-sorted list is already within 2.6% of even at 8 shards and 6.8% at 16. The new split is exact (every listing in one bucket, none twice) and levels the bytes, so the upper bound on the wall-clock gain here is those few percent, as far as listing size predicts translation time; I did not time a translation run. The 1.18x / 1.30x figures in the docstring would be worth labelling as the synthetic worst case. Read
AI-assisted (Claude Code). |
|
That is exactly the measurement this PR was missing — thank you. I have replaced the numbers in the description with yours, because mine were taken on a synthetic corpus whose skew (largest listing 10% of the total) is nothing like the real one (0.20%, 143x the median). The honest claim is now:
The partition is exact either way (your "partition exact: yes" at every shard count), the bytes are level at 1.000 of the mean, and a corpus with no skew costs nothing. So the change is a strict improvement with a small denominator — and if it is not worth carrying for 0-7%, closing it is the right call; the measurement above is the reason, and it should stay on the record rather than be argued with. |
|
Tested 30ade56 on Steam Deck LCD (Jupiter), AMD Custom GPU 0405 "Van Gogh", RADV Mesa 26.2.0-devel (git-5c65d4fc31), Vulkan 1.4.350, SteamOS 3.9.5 (holo), kernel 7.2.7-valve2-2-neptune-72-g31504582a073: pass
AI-assisted (OpenCode). |
|
Tested 30ade56 on Windows 11, Python 3.15.2, NVIDIA RTX 4060 Ti (driver 621.24; CPU-only checks, no game files, no GPU/llvm-mc/MSVC used): pass. Ran the test files this PR adds or changes, from a clean checkout of the PR head: AI-assisted (Claude Code). |
|
Tested I checked the resume path too: the saved plan includes the translator digest, so it drops old shard parts when the partitioning code changes. This was a fixture run, no benchmark on the full corpus. AI-assisted testing and review. |
|
Tested the I used two synthetic files, A (20 bytes) and B (10 bytes), and two workers. With normal size lookups the workers select A and B respectively. I then made only worker 0's Could a failed size lookup abort that worker before it publishes a part? That would allow a retry once the file is accessible. A regression test can inject a lookup failure in just one worker and require an error rather than a changed partition. No translation or game data was needed. AI-assisted. |
…sing 0 Reported by @Zhenyettta on ItsNotRexed#7479: with a weight of 0 for an unreadable file, two shards can take the same shader while another one falls out of every bucket, and the merge then publishes a set with a duplicate and a hole. Every shard derives the partition alone from the same listing, so the one thing that must not happen is a shard placing a file by a number the others do not have. The size lookup now raises with the path and the advice to run the shard again; a transient failure becomes a retry instead of a silently wrong set.
|
You are right, and I took the stricter option you suggested: a size the shard cannot read now stops the run instead of being guessed at as 0. The reason it has to be the strict one: each shard derives the partition on its own from the same listing, so the invariant is that every shard places every file by the same number. A
|
|
AI-assisted Linux CLI check at With unchanged sources both trees published all 8 names exactly once. I then repeated the experiment eight times, appending only a 28 KB comment to a different listing between the two shard commands. All listings remained readable and the list of filenames stayed constant.
In those four cases the resized input itself disappeared from the merged index. All shard and merge subprocesses exited 0; zero skips. Rerunning both shards after the edit restored 8/8 with no overlap. An unreadable size now stops a shard, but a readable size changing between processes can still silently publish an incomplete index. |
|
Tested
Baseline on AI-assisted (Claude Code). |
Claimed in the coordination issue: #7049
What and why
--shard i/ntookfiles[index::count]. Shaders differ in size by two orders of magnitude (a mesh or geometry shaderagainst a small pixel shader), so a round-robin split can hand one shard most of the work, and a parallel stage is as
slow as its heaviest shard — the other processes finish and idle.
shard_bucket()sorts the listing by file size, largest first, and gives each file to the lightest bucket so far; ashard then translates its own bucket. Every shard computes the same partition from the same directory listing, so this
needs no coordination between processes and no change to
make_game.pyor to the--shard i/ninterface, and eachbucket is still handed out in name order.
Numbers
On the real listing set (@exotiquee, 26,503
.sfiles, 3,533 MiB, sizes fromos.path.getsize,shard_bucketimported from this head; counts only, no game data):
files[i::n]max/meanfiles[i::n]min/meanshard_bucketmax/meanThe largest listing is 0.20% of the total (143x the median), so round-robin over the name-sorted list is already
within 2.6% of even at 8 shards and 6.8% at 16 — that, not the synthetic number below, is the upper bound of what
this can buy, as far as listing size predicts translation time. The split is exact in either case (every listing in one
bucket, none twice) and levels the bytes, so the change removes the tail rather than rescaling the stage.
My synthetic corpus was skewed far more than the real one, which is why its 1.17x / 1.18x / 1.26x is not the claim:
shard_bucket(synthetic, largest 10% of the total)Kept for the case the change is written for — one shard collecting most of the work — but the real corpus is not that
case, and the honest expected gain there is 0-7%, growing with the shard count. If the maintainer prefers not to
carry a change for that, closing this is the right call and the measurement above is the reason.
Equivalence and tests
tests/test_rdna2spirv_shard.py(new, 5 tests): the buckets are disjoint and complete for 1/2/3/4/8/16 shards, thesame partition in every process, name order inside a bucket, a skewed listing beats
files[::n]at 2/4/8 shards, oneshard takes everything, and a file whose size cannot be read stops the shard with its path in the message instead
of being placed by a guessed weight (@Zhenyettta's finding, below).
would place a file by a number the others do not have, take a file another shard already took, and leave a third one
out of every bucket.
shard_bucket()raises instead, and the run is retried.tests/test_rdna2spirv_merge.pyand the--mergepath are unchanged: parts are still per shard index, and the mergedoes not depend on which shard translated which shader.
python -m compileall -q tools testsclean.--limitstill applies before the partition, so a limited run keeps its old meaning.I could not run
--shardend to end here: the CLI validates withspirv-as/spirv-val, which this machine does nothave, so the numbers above come from the translator's own
translate()on the same files the buckets would receive.cc @ItsNotRexed @KoertLichtendonk.
Checklist
docs/design.md. (Not applicable: no translation change; thesame shaders are translated, by a different process.)