Chandler Carruth
34cf614a26
Improve register allocation across HashSizedBytesLarge calls (#8119)
Because this function was a non-static member function, calls passed
`this` across the call boundary, and the caller assumed it might clobber
the memory of `Hasher`.
This PR changes it to a `[[gnu::pure]]` and `static` function which
takes and returns a `uint64_t` by value like other static helpers.
Between knowing this does not write to memory and the state being passed
in and out in registers, this allows `Hasher` to stay in a single
register across all size classes, reducing stack memory accesses and
code size.
On an AMD Ryzen 9 9950X (Zen 5), hashtable and lexer benchmarks vs
`trunk` (10 runs; negative means faster):
| Hashtable benchmark | x86-64-v3 | x86-64-v2 |
| :---------------------- | ----------------: | ----------------: |
| BM_SetContainsHitPtr | -2.1% (-4..+1%) | -1.1% (-3..+5%) |
| BM_SetLookupHitPtr | -2.8% (-4..-1%) | -2.7% (-7..-2%) |
| BM_SetEraseInsertHitPtr | +1.0% (-1..+6%) | +1.8% (-0..+5%) |
| BM_SetInsertSeq | -2.7% (-3..-2%) | -2.6% (-3..-2%) |
| BM_MapContainsHit | -2.7% (-4..-0%) | -3.7% (-8..-1%) |
| BM_MapUpdateHit | -6.2% (-9..-2%) | -5.6% (-10..+2%) |
| BM_MapLookupHit | -2.4% (-9..-1%) | -1.1% (-3..+2%) |
| BM_MapInsertSeq | -2.4% (-4..-1%) | -0.5% (-3..+1%) |
| 4-Hit-Family Mean | -3.47% | -3.28% |
| Lexer benchmark | x86-64-v3 | x86-64-v2 |
| :------------------------------- | --------------: | --------------: |
| BM_ValidIdentifiers | +0.1% (-1..+1%) | -0.8% (-3..+1%) |
| BM_ValidKeywords | -1.3% | +0.9% |
| BM_ValidKeywordsAsRawIdentifiers | +0.0% | +1.8% |
| BM_RawIdentifierFocus | +0.7% | -0.3% |
| BM_RandomSource | +0.8% | -0.0% |
Zen 5 x86-64-v3 per-lookup hardware counters (`BM_SetContainsHitPtr`):
| Size/Keys | Variant | Cycles | Instrs | Ops |
| :-------- | :------ | -----------: | -----------: | -----------: |
| 4096/256 | trunk | 18.20 | 98.54 | 89.27 |
| 4096/256 | after | 17.51 (-0.7) | 95.92 (-2.6) | 87.63 (-1.6) |
| 4096/2048 | trunk | 19.63 | 98.39 | 89.11 |
| 4096/2048 | after | 18.99 (-0.6) | 95.90 (-2.5) | 87.62 (-1.5) |
Assisted-by: Antigravity with various models
2026-11-20 21:57:55 +00:00
..
2026-10-30 07:25:03 +00:00
2024-01-05 23:01:47 +00:00
2026-07-15 00:47:47 +00:00
2026-07-15 00:47:47 +00:00
2026-01-01 22:20:40 +00:00
2026-10-27 21:05:53 +00:00
2025-05-12 23:46:02 +00:00
2025-05-12 23:46:02 +00:00
2025-05-12 19:01:01 +00:00
2025-05-12 23:46:02 +00:00
2025-05-12 23:46:02 +00:00
2026-07-13 22:29:39 +00:00
2026-07-13 22:29:39 +00:00
2025-05-28 22:48:20 +00:00
2025-05-30 16:20:43 +00:00
2026-10-15 15:30:08 +00:00
2025-05-28 22:48:20 +00:00
2026-01-20 23:07:30 +00:00
2026-01-20 23:07:30 +00:00
2025-05-16 01:39:19 +00:00
2025-06-10 13:37:16 +00:00
2025-06-10 13:37:16 +00:00
2025-09-12 22:59:37 +00:00
2025-02-14 17:54:39 +00:00
2025-11-14 13:50:56 +00:00
2025-09-12 22:59:37 +00:00
2025-09-12 22:59:37 +00:00
2026-01-21 17:41:46 +00:00
2025-08-25 16:28:11 +00:00
2025-09-10 13:47:59 +00:00
2025-06-12 16:05:11 +00:00
2025-06-12 16:05:11 +00:00
2025-10-13 18:49:48 +00:00
2026-10-02 00:15:21 +00:00
2026-08-19 21:54:46 +00:00
2026-08-19 21:54:46 +00:00
2026-08-19 21:54:46 +00:00
2025-04-18 14:17:48 +00:00
2026-09-11 00:22:27 +00:00
2025-06-10 23:21:17 +00:00
2025-06-10 23:21:17 +00:00
2026-10-06 15:13:10 +00:00
2026-10-06 15:13:10 +00:00
2026-11-20 21:57:55 +00:00
2026-11-20 21:57:55 +00:00
2026-11-20 21:57:55 +00:00
2026-10-06 15:13:10 +00:00
2026-10-06 15:13:10 +00:00
2026-10-14 14:12:56 +00:00
2024-10-13 17:47:57 +00:00
2024-01-05 23:01:47 +00:00
2025-11-15 02:00:41 +00:00
2025-11-15 02:00:41 +00:00
2025-11-15 02:00:41 +00:00
2026-10-02 00:15:21 +00:00
2026-09-18 20:19:46 +00:00
2026-09-18 20:19:46 +00:00
2025-05-07 22:20:39 +00:00
2026-08-19 01:00:13 +00:00
2026-08-19 01:00:13 +00:00
2026-10-27 21:05:53 +00:00
2026-10-27 21:05:53 +00:00
2025-06-26 20:28:21 +00:00
2026-10-06 15:13:10 +00:00
2026-10-06 15:13:10 +00:00
2026-10-02 00:15:21 +00:00
2024-06-08 01:50:02 +00:00
2025-11-15 03:37:13 +00:00
2026-10-06 15:13:10 +00:00
2026-10-06 15:13:10 +00:00
2026-10-06 15:13:10 +00:00
2025-01-18 01:11:44 +00:00
2026-09-10 19:12:00 +00:00
2026-10-02 00:15:21 +00:00
2026-09-18 20:19:46 +00:00
2026-10-26 06:38:17 +00:00
2026-01-07 02:53:31 +00:00
2026-01-07 02:53:31 +00:00
2026-01-07 02:53:31 +00:00
2026-09-10 21:26:37 +00:00
2026-09-10 21:26:37 +00:00
2025-10-29 16:52:46 +00:00
2025-10-29 16:52:46 +00:00
2025-09-10 13:47:59 +00:00
2024-06-18 00:33:05 +00:00
2024-06-18 00:33:05 +00:00
2024-06-18 00:33:05 +00:00
2025-04-17 15:37:57 +00:00
2024-09-16 22:55:55 +00:00