Files
carbon-lang/common
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
..
2025-05-16 01:39:19 +00:00
2025-10-13 18:49:48 +00:00
2024-10-13 17:47:57 +00:00
2024-01-05 23:01:47 +00:00
2024-09-16 22:55:55 +00:00