Commit 46b464c
committed
fix(dispatch): reduce locking contention
Reduce the amount of time spent holding locks in the dispatcher:
- doMaintenance() holds RW lock only during deletion
- Groups() holds R lock, copies, releases
- processAlert() holds R(W) locks only when necessary
This results in -70% maintenance overhead or +19518.99% alert processing rate improvement:
```
│ bench-dispatch-main.txt │ bench-dispatch-fix-locking.txt │
│ baseline_alerts/sec │ baseline_alerts/sec vs base │
Dispatch_100k_AggregationGroups_10k_Empty-12 1.899M ± 1% 1.919M ± 2% ~ (p=0.063 n=10)
Dispatch_100k_AggregationGroups_20k_Empty-12 1.934M ± 2% 1.967M ± 1% +1.69% (p=0.015 n=10)
Dispatch_100k_AggregationGroups_30k_Empty-12 1.926M ± 3% 1.931M ± 4% ~ (p=0.436 n=10)
Dispatch_100k_AggregationGroups_40k_Empty-12 2.087M ± 10% 2.030M ± 7% ~ (p=0.912 n=10)
Dispatch_100k_AggregationGroups_50k_Empty-12 1.922M ± 3% 2.118M ± 10% +10.16% (p=0.000 n=10)
Dispatch_20k_AggregationGroups_Groups_Impact-12 180.7k ± 42% 2128.6k ± 4% +1077.93% (p=0.000 n=10)
Dispatch_50k_AggregationGroups_Groups_Impact-12 57.02k ± 196% 2089.55k ± 2% +3564.69% (p=0.000 n=10)
Dispatch_100k_AggregationGroups_Groups_Impact-12 19.61k ± 35% 1899.27k ± 2% +9582.74% (p=0.000 n=10)
geomean 524.6k 2.008M +282.84%
│ bench-dispatch-main.txt │ bench-dispatch-fix-locking.txt │
│ maintenance_overhead_% │ maintenance_overhead_% vs base │
Dispatch_100k_AggregationGroups_10k_Empty-12 17.185 ± 7% 5.672 ± 45% -66.99% (p=0.000 n=10)
Dispatch_100k_AggregationGroups_20k_Empty-12 36.50 ± 11% 12.56 ± 14% -65.59% (p=0.000 n=10)
Dispatch_100k_AggregationGroups_30k_Empty-12 55.44 ± 13% 23.11 ± 30% -58.32% (p=0.000 n=10)
Dispatch_100k_AggregationGroups_40k_Empty-12 125.65 ± 27% 28.98 ± 53% -76.94% (p=0.000 n=10)
Dispatch_100k_AggregationGroups_50k_Empty-12 172.40 ± 36% 37.76 ± 82% -78.10% (p=0.000 n=10)
geomean 59.62 17.83 -70.10%
```
Signed-off-by: Siavash Safi <[email protected]>1 parent 36f835d commit 46b464c
File tree
3 files changed
+490
-58
lines changed- dispatch
3 files changed
+490
-58
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
| 25 | + | |
24 | 26 | | |
25 | 27 | | |
26 | 28 | | |
| |||
41 | 43 | | |
42 | 44 | | |
43 | 45 | | |
44 | | - | |
45 | | - | |
| 46 | + | |
46 | 47 | | |
47 | 48 | | |
48 | 49 | | |
| |||
84 | 85 | | |
85 | 86 | | |
86 | 87 | | |
87 | | - | |
88 | | - | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
89 | 92 | | |
90 | 93 | | |
91 | 94 | | |
| |||
134 | 137 | | |
135 | 138 | | |
136 | 139 | | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
141 | 151 | | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
| 152 | + | |
147 | 153 | | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
148 | 167 | | |
149 | 168 | | |
150 | 169 | | |
151 | 170 | | |
152 | 171 | | |
153 | 172 | | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
158 | 180 | | |
159 | | - | |
160 | | - | |
161 | | - | |
| 181 | + | |
| 182 | + | |
162 | 183 | | |
163 | | - | |
164 | 184 | | |
165 | | - | |
| 185 | + | |
166 | 186 | | |
167 | | - | |
| 187 | + | |
168 | 188 | | |
169 | 189 | | |
170 | | - | |
| 190 | + | |
| 191 | + | |
171 | 192 | | |
172 | 193 | | |
173 | 194 | | |
| |||
197 | 218 | | |
198 | 219 | | |
199 | 220 | | |
200 | | - | |
| 221 | + | |
201 | 222 | | |
202 | 223 | | |
203 | 224 | | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
208 | | - | |
209 | | - | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
210 | 233 | | |
211 | 234 | | |
212 | 235 | | |
213 | 236 | | |
214 | 237 | | |
215 | | - | |
| 238 | + | |
216 | 239 | | |
217 | 240 | | |
218 | 241 | | |
| |||
236 | 259 | | |
237 | 260 | | |
238 | 261 | | |
239 | | - | |
240 | 262 | | |
241 | 263 | | |
242 | | - | |
243 | | - | |
244 | | - | |
245 | | - | |
246 | | - | |
247 | | - | |
248 | | - | |
249 | | - | |
250 | | - | |
251 | | - | |
252 | | - | |
253 | | - | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
254 | 268 | | |
255 | 269 | | |
256 | 270 | | |
257 | | - | |
258 | | - | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
259 | 275 | | |
260 | | - | |
| 276 | + | |
261 | 277 | | |
262 | 278 | | |
263 | | - | |
264 | | - | |
265 | | - | |
266 | | - | |
267 | 279 | | |
268 | 280 | | |
269 | 281 | | |
270 | 282 | | |
271 | 283 | | |
272 | | - | |
| 284 | + | |
273 | 285 | | |
274 | | - | |
| 286 | + | |
275 | 287 | | |
276 | 288 | | |
277 | 289 | | |
| |||
0 commit comments