Commit cc3372d
perf(internal/bits): Additional speedup to
Closes cometbft#2849
before & after, we observed roughly 30% speed up with this refactor
```goos: linux
goarch: amd64
pkg: github.com/cometbft/cometbft/internal/bits
cpu: 13th Gen Intel(R) Core(TM) i5-13400
BenchmarkPickRandomBitArray-16 15392144 65.31 ns/op 0 B/op 0 allocs/op
PASS
```
```goos: linux
goarch: amd64
pkg: github.com/cometbft/cometbft/internal/bits
cpu: 13th Gen Intel(R) Core(TM) i5-13400
BenchmarkPickRandomBitArray-16 24890334 44.16 ns/op 0 B/op 0 allocs/op
PASS
```
---
#### PR checklist
- [x] Tests written/updated
- [ ] Changelog entry added in `.changelog` (we use
[unclog](https://github.com/informalsystems/unclog) to manage our
changelog)
- [ ] Updated relevant documentation (`docs/` or `spec/`) and code
comments
---------
Co-authored-by: Anton Kaliaev <[email protected]>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>bitArray.PickRandom (cometbft#4675)1 parent 21024b7 commit cc3372d
File tree
3 files changed
+64
-35
lines changed- .changelog/unreleased/improvements
- internal/bits
3 files changed
+64
-35
lines changedLines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
19 | | - | |
20 | | - | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| |||
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
30 | | - | |
31 | | - | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
32 | 34 | | |
33 | 35 | | |
34 | 36 | | |
| |||
40 | 42 | | |
41 | 43 | | |
42 | 44 | | |
43 | | - | |
44 | | - | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
45 | 48 | | |
46 | 49 | | |
47 | 50 | | |
48 | 51 | | |
49 | 52 | | |
| 53 | + | |
50 | 54 | | |
51 | 55 | | |
52 | 56 | | |
| |||
93 | 97 | | |
94 | 98 | | |
95 | 99 | | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
96 | 103 | | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
97 | 107 | | |
98 | 108 | | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
99 | 112 | | |
100 | 113 | | |
101 | 114 | | |
| |||
115 | 128 | | |
116 | 129 | | |
117 | 130 | | |
118 | | - | |
119 | | - | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
120 | 134 | | |
121 | 135 | | |
122 | 136 | | |
123 | 137 | | |
124 | 138 | | |
125 | 139 | | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
126 | 148 | | |
127 | | - | |
128 | | - | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
129 | 152 | | |
130 | 153 | | |
131 | 154 | | |
| |||
193 | 216 | | |
194 | 217 | | |
195 | 218 | | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
196 | 222 | | |
197 | 223 | | |
198 | 224 | | |
| |||
268 | 294 | | |
269 | 295 | | |
270 | 296 | | |
271 | | - | |
272 | | - | |
| 297 | + | |
273 | 298 | | |
274 | 299 | | |
275 | 300 | | |
276 | | - | |
| 301 | + | |
277 | 302 | | |
278 | 303 | | |
279 | 304 | | |
280 | 305 | | |
281 | 306 | | |
282 | 307 | | |
283 | 308 | | |
284 | | - | |
285 | | - | |
286 | | - | |
287 | | - | |
288 | | - | |
289 | | - | |
290 | | - | |
291 | | - | |
292 | | - | |
293 | | - | |
294 | | - | |
295 | | - | |
296 | | - | |
297 | | - | |
298 | | - | |
299 | | - | |
300 | | - | |
301 | 309 | | |
302 | 310 | | |
303 | 311 | | |
| |||
442 | 450 | | |
443 | 451 | | |
444 | 452 | | |
| 453 | + | |
445 | 454 | | |
446 | 455 | | |
447 | 456 | | |
| |||
459 | 468 | | |
460 | 469 | | |
461 | 470 | | |
| 471 | + | |
462 | 472 | | |
463 | 473 | | |
464 | 474 | | |
| |||
468 | 478 | | |
469 | 479 | | |
470 | 480 | | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
471 | 489 | | |
472 | 490 | | |
473 | 491 | | |
| 492 | + | |
474 | 493 | | |
475 | 494 | | |
476 | 495 | | |
| |||
498 | 517 | | |
499 | 518 | | |
500 | 519 | | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
501 | 528 | | |
502 | 529 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
79 | | - | |
| 79 | + | |
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
| |||
170 | 170 | | |
171 | 171 | | |
172 | 172 | | |
173 | | - | |
| 173 | + | |
174 | 174 | | |
175 | | - | |
176 | | - | |
| 175 | + | |
| 176 | + | |
177 | 177 | | |
178 | 178 | | |
179 | 179 | | |
| |||
0 commit comments