Commit fa6ccb0
committed
stream: move addrConnStream.mu to cache line 2 to eliminate false sharing
sentLast, receivedFirstMsg, and decompressorSet are all written without
holding mu (they are written in CloseSend and recvMsg during normal stream
operation). After the tail-grouping commit they landed at offset 232–234
(cache line 3: 192–255), the same cache line as mu (offset 224). Concurrent
writes to these fields invalidate the cache line before every mu.Lock(),
adding up to ~18× overhead under concurrent load.
Moving mu to immediately before parser places it at offset 184 (cache line 2:
128–191). The tail bools remain at offset 232+ (cache line 3), so stressor
writes no longer affect mu.Lock() latency.
Benchmark before this commit (sentLast stressor):
stressors=0 3.9 ns
stressors=1 19.1 ns (4.9×)
stressors=4 69.1 ns (17.7×)
Benchmark after (different cache lines):
stressors=0 3.7 ns
stressors=1 3.7 ns (~1×)
stressors=4 3.9 ns (~1×)
No size change: addrConnStream remains 240 B.
Fixes #93481 parent 852e985 commit fa6ccb0
1 file changed
Lines changed: 6 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1502 | 1502 | | |
1503 | 1503 | | |
1504 | 1504 | | |
1505 | | - | |
1506 | | - | |
1507 | | - | |
| 1505 | + | |
| 1506 | + | |
1508 | 1507 | | |
1509 | 1508 | | |
1510 | | - | |
| 1509 | + | |
| 1510 | + | |
| 1511 | + | |
| 1512 | + | |
1511 | 1513 | | |
1512 | 1514 | | |
1513 | 1515 | | |
| |||
0 commit comments