upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/tests/test_run_gpu_tests_python_assembler.py
diff options
context:
space:
mode:
authorbobcatchris <83428450+bobcatchris@users.noreply.github.com>2026-11-30 08:55:33 -0600
committerbobcatchris <83428450+bobcatchris@users.noreply.github.com>2026-11-30 08:55:33 -0600
commitb6ab4c745b1711e539dd397e77bff478e593fcee (patch)
treefd0c22b269901e26b364eb9af7d661154cfad246 /tests/test_run_gpu_tests_python_assembler.py
parentf44904d21cb64c7c2121905f49ff50f6cd2b132d (diff)
leonida-shader: hash the translator's tables with a multiply hasher, not SipHash (D3D12-SHADER-FAST-HASH)
`std::collections::HashMap` hashes with SipHash. The keys of the translator's tables are numbers it made itself (values, blocks, types, sites) while reading the user's own file, so nothing gains from SipHash's resistance to chosen keys, and `structure.rs` already says "SipHash dominated run time" about its BDD tables and has its own hasher for them. The others did not. In a sampling profile of a whole-archive `leonida translate` (24,055 samples, 5 ms, 16 threads) SipHash was under a frame of the translator in 21 % of the samples: 13.7 % in `Module::merge` (the value-numbering tables `known`, `read` and `Facts` of `emit/bitcode/opt.rs`), 1.6 % in the interning tables of `emit/bitcode.rs`, 1.2 % in `io::raise`, 1.7 % in `Lower::new` and `Lower::computed_with`, and the rest in the `Lower` tables. New `fxhash.rs`: `FxHasher` (a multiplication per word and a rotation of the product, so that the well mixed high bits are where a table takes its bucket from), `FxHashMap` and `FxHashSet`. Used for the tables of `Module` (types, constants, functions), of `Module::merge` (`known`, `read`, `joins`, `Facts`), of `io::raise` and the tables `Lower` and its paired `LaneState` keep by value, block, site and descriptor. Only tables that are looked up, or walked for a result that is the same in any order (`read_phis`, a closure); `structure.rs` and the tables that are iterated for their order are left as they were. After it SipHash is under 1 % of the samples (230 of 23,545). - fxhash::tests: equal keys hash equal and near keys, a string and the same with zeros after it, and slices of different length differ; the low bits (a bucket) and the top seven (a tag) of the hashes of 131,072 small numbers, multiples of 4,096 and 65,536, pairs and triples spread within 3 times the mean (without the rotation of the product, the multiples of 4,096 all land in one bucket and it fails); a map with the hasher agrees with a `BTreeMap` over 20,000 random inserts, removals and lookups. Output unchanged: `leonida translate` over the whole archive, the DXIL of all 25,689 emitted programs (15,799 distinct) hashes the same in every run of the old and new builds (12 runs, both heaps). Full archive, Ryzen 7 7800X3D (16 threads), --release, alternating, system heap: 63.8/64.1/ 64.2 s wall and 885/889/889 CPU-seconds -> 58.6/58.4/59.0 s and 797/794/ 802; with mimalloc (the game's build): 45.4/45.1/45.3 s and 636/633/633 -> 40.6/40.2/41.6 s and 562/558/562. AI-assisted: Claude Sonnet 5.5 Co-authored-by: Cursor <cursoragent@cursor.com>
Diffstat (limited to 'tests/test_run_gpu_tests_python_assembler.py')
0 files changed, 0 insertions, 0 deletions