Commit 3210d16
committed
[#2275] Switch usage counter to AtomicLong
A three-way benchmark of the counter primitive (TopicRawThroughputBenchmark,
topic-per-producer, direct dispatch, 0 consumers, JDK 25, 11-core Apple M3
Pro, msgs/sec) showed the striped LongAdder buys nothing measurable over a
plain AtomicLong at 1-22 producer threads:
threads RW-lock (pre-#2275) AtomicLong LongAdder
1 5.12M +/- 0.10 5.85M +/- 0.11 5.79M +/- 0.10
4 1.48M +/- 0.12 7.03M +/- 0.94 6.93M +/- 1.04
8 1.28M +/- 0.11 5.01M +/- 0.41 5.92M +/- 0.27
22 1.17M +/- 0.09 4.98M +/- 1.53 4.85M +/- 0.59
The 4-6x win over the old ReentrantReadWriteLock comes from removing
blocking (park/unpark convoys), not from striping; at the broker's achieved
message rates (~2 CAS per message on the shared parent) a single AtomicLong
cache line is nowhere near saturation on this class of hardware. The lone
LongAdder edge (8 threads) does not persist at 22 and is within run-to-run
wobble of that regime.
AtomicLong is perferrable over LongAdder for simplicity.
Validation: MemoryUsageConcurrencyTest (4, incl. the concurrent setUsage
drift aggressive test and the 150-round untimed waitForSpace liveness soak)
and MemoryUsageTest (5) pass; ProducerFlowControlTest,
ProducerFlowControlSendFailTest and TopicProducerFlowControlTest (18) pass.1 parent 3ebd8d3 commit 3210d16
1 file changed
Lines changed: 17 additions & 17 deletions
Lines changed: 17 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
| 20 | + | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
37 | 40 | | |
38 | 41 | | |
39 | 42 | | |
| |||
166 | 169 | | |
167 | 170 | | |
168 | 171 | | |
169 | | - | |
| 172 | + | |
170 | 173 | | |
171 | 174 | | |
172 | 175 | | |
| |||
186 | 189 | | |
187 | 190 | | |
188 | 191 | | |
189 | | - | |
| 192 | + | |
190 | 193 | | |
191 | 194 | | |
192 | 195 | | |
| |||
214 | 217 | | |
215 | 218 | | |
216 | 219 | | |
217 | | - | |
| 220 | + | |
218 | 221 | | |
219 | 222 | | |
220 | 223 | | |
221 | 224 | | |
222 | | - | |
| 225 | + | |
223 | 226 | | |
224 | 227 | | |
225 | 228 | | |
226 | | - | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | | - | |
231 | | - | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
232 | 232 | | |
233 | 233 | | |
234 | | - | |
| 234 | + | |
235 | 235 | | |
236 | 236 | | |
237 | 237 | | |
| |||
0 commit comments