Commit f30bfa9
authored
Add frozen support to roaring64 (#688)
* Array-backed ART
* Array-backed r64
* ART serialization
* r64 frozen serialization
* Synthetic benchmarks for r64
* Address review comments
* Add random insert / remove benchmark
* Link free nodes together
This adds the index of the next free node into a newly freed node, or `capacity` if there are no more free indices.
This significantly speeds up finding the next free index, which is important for add+remove workloads.
Benchmarks
Old:
------------------------------------------------------------------
Benchmark Time CPU Iterations
------------------------------------------------------------------
r64InsertRemoveRandom/0 127 ns 127 ns 5461079
r64InsertRemoveRandom/1 31633 ns 31604 ns 24028
r64InsertRemoveRandom/2 30782 ns 30769 ns 21859
r64InsertRemoveRandom/3 31985 ns 31969 ns 21558
r64InsertRemoveRandom/4 356 ns 356 ns 1962694
r64InsertRemoveRandom/5 28972 ns 28962 ns 21366
r64InsertRemoveRandom/6 30632 ns 30623 ns 22682
r64InsertRemoveRandom/7 448 ns 448 ns 1601550
r64InsertRemoveRandom/8 32506 ns 32495 ns 21591
r64InsertRemoveRandom/9 689 ns 689 ns 1002237
cppInsertRemoveRandom/0 131 ns 131 ns 5319673
cppInsertRemoveRandom/1 16106 ns 16104 ns 43632
cppInsertRemoveRandom/2 3881 ns 3881 ns 180087
cppInsertRemoveRandom/3 3582 ns 3582 ns 171298
cppInsertRemoveRandom/4 403 ns 402 ns 1666697
cppInsertRemoveRandom/5 993 ns 993 ns 706038
cppInsertRemoveRandom/6 4039 ns 4038 ns 172421
cppInsertRemoveRandom/7 469 ns 469 ns 1440197
cppInsertRemoveRandom/8 1454 ns 1454 ns 633551
cppInsertRemoveRandom/9 654 ns 654 ns 1091588
setInsertRemoveRandom/0 1944 ns 1943 ns 368926
setInsertRemoveRandom/1 1955 ns 1953 ns 404931
setInsertRemoveRandom/2 1911 ns 1910 ns 358466
setInsertRemoveRandom/3 1953 ns 1951 ns 362351
setInsertRemoveRandom/4 2104 ns 2102 ns 321387
setInsertRemoveRandom/5 1944 ns 1943 ns 354836
setInsertRemoveRandom/6 1835 ns 1835 ns 359099
setInsertRemoveRandom/7 1970 ns 1968 ns 372625
setInsertRemoveRandom/8 1894 ns 1892 ns 355456
setInsertRemoveRandom/9 1659 ns 1659 ns 355902
New:
------------------------------------------------------------------
Benchmark Time CPU Iterations
------------------------------------------------------------------
r64InsertRemoveRandom/0 128 ns 128 ns 5614266
r64InsertRemoveRandom/1 935 ns 935 ns 739679
r64InsertRemoveRandom/2 916 ns 916 ns 739944
r64InsertRemoveRandom/3 936 ns 936 ns 690708
r64InsertRemoveRandom/4 368 ns 368 ns 1957642
r64InsertRemoveRandom/5 1141 ns 1140 ns 592505
r64InsertRemoveRandom/6 1139 ns 1138 ns 657840
r64InsertRemoveRandom/7 481 ns 481 ns 1434967
r64InsertRemoveRandom/8 1447 ns 1446 ns 484463
r64InsertRemoveRandom/9 721 ns 721 ns 1017456
cppInsertRemoveRandom/0 134 ns 134 ns 5524804
cppInsertRemoveRandom/1 15616 ns 15608 ns 47666
cppInsertRemoveRandom/2 3855 ns 3854 ns 180265
cppInsertRemoveRandom/3 3809 ns 3808 ns 183595
cppInsertRemoveRandom/4 412 ns 412 ns 1695708
cppInsertRemoveRandom/5 1012 ns 1011 ns 713501
cppInsertRemoveRandom/6 3410 ns 3409 ns 199214
cppInsertRemoveRandom/7 474 ns 474 ns 1496740
cppInsertRemoveRandom/8 1421 ns 1420 ns 465868
cppInsertRemoveRandom/9 564 ns 564 ns 1148076
setInsertRemoveRandom/0 1956 ns 1956 ns 351283
setInsertRemoveRandom/1 1959 ns 1958 ns 355766
setInsertRemoveRandom/2 1886 ns 1885 ns 357406
setInsertRemoveRandom/3 1905 ns 1904 ns 355235
setInsertRemoveRandom/4 1945 ns 1944 ns 364599
setInsertRemoveRandom/5 1902 ns 1902 ns 350312
setInsertRemoveRandom/6 1907 ns 1906 ns 346962
setInsertRemoveRandom/7 1937 ns 1936 ns 356168
setInsertRemoveRandom/8 1881 ns 1880 ns 341472
setInsertRemoveRandom/9 1962 ns 1961 ns 350643
* Sort free lists in art_shrink_to_fit
This avoids a bug in the following scenario:
art->leaves = [2,0,x]
art->first_free[leaf_type] = 1
Where `2` and `0` are pointers to the next free index, and `x` is an occupied
leaf. In this case, if `art_shrink_to_fit` was called, then we would have the
following result:
art->leaves = [2,x,0]
art->first_free[leaf_type] = 0
This is not fully shrunken, and therefore wrong. Sorting the free indices fixes
this scenario. Before `art_shrink_to_fit`:
art->leaves = [1,2,x]
art->first_free[leaf_type] = 0
After `art_shrink_to_fit`:
art->leaves = [x,2,3]
art->first_free[leaf_type] = 1
* Minor cleanups to ART and r64 internals
* Replace size_t with uint64_t where applicable
Also replace malloc+memset with calloc.
* Use a generic pointer array for ART nodes
This, combined with a static array of node type sizes, allows us to generically manipulate the nodes.
* Correct outdated comment
* Always try to shrink containers
* Replace size_t with uint64_t where applicable in r64
* Check if ART is shrunken when checking if r64 is shrunken1 parent 34b2271 commit f30bfa9
File tree
8 files changed
+2929
-1124
lines changed- include/roaring
- art
- microbenchmarks
- src
- art
- tests
8 files changed
+2929
-1124
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
23 | | - | |
| 22 | + | |
| 23 | + | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
37 | 43 | | |
38 | 44 | | |
39 | | - | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
40 | 50 | | |
41 | 51 | | |
42 | | - | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
43 | 60 | | |
44 | 61 | | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
| 62 | + | |
55 | 63 | | |
56 | 64 | | |
57 | 65 | | |
| |||
63 | 71 | | |
64 | 72 | | |
65 | 73 | | |
66 | | - | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
67 | 81 | | |
68 | | - | |
| 82 | + | |
69 | 83 | | |
70 | 84 | | |
71 | | - | |
| 85 | + | |
| 86 | + | |
72 | 87 | | |
73 | | - | |
| 88 | + | |
74 | 89 | | |
75 | 90 | | |
76 | 91 | | |
| |||
83 | 98 | | |
84 | 99 | | |
85 | 100 | | |
86 | | - | |
87 | | - | |
| 101 | + | |
| 102 | + | |
88 | 103 | | |
89 | 104 | | |
90 | 105 | | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | 106 | | |
98 | 107 | | |
99 | 108 | | |
100 | 109 | | |
101 | 110 | | |
102 | 111 | | |
103 | | - | |
| 112 | + | |
| 113 | + | |
104 | 114 | | |
105 | 115 | | |
106 | 116 | | |
107 | 117 | | |
108 | 118 | | |
109 | | - | |
| 119 | + | |
| 120 | + | |
110 | 121 | | |
111 | 122 | | |
112 | | - | |
| 123 | + | |
| 124 | + | |
113 | 125 | | |
114 | 126 | | |
115 | | - | |
| 127 | + | |
116 | 128 | | |
117 | 129 | | |
118 | 130 | | |
119 | 131 | | |
120 | 132 | | |
121 | | - | |
| 133 | + | |
122 | 134 | | |
123 | 135 | | |
124 | 136 | | |
| |||
130 | 142 | | |
131 | 143 | | |
132 | 144 | | |
| 145 | + | |
| 146 | + | |
133 | 147 | | |
134 | 148 | | |
135 | 149 | | |
| |||
143 | 157 | | |
144 | 158 | | |
145 | 159 | | |
146 | | - | |
| 160 | + | |
147 | 161 | | |
148 | 162 | | |
149 | 163 | | |
150 | 164 | | |
151 | 165 | | |
152 | | - | |
| 166 | + | |
153 | 167 | | |
154 | 168 | | |
155 | 169 | | |
156 | 170 | | |
157 | 171 | | |
158 | | - | |
| 172 | + | |
159 | 173 | | |
160 | 174 | | |
161 | 175 | | |
| |||
174 | 188 | | |
175 | 189 | | |
176 | 190 | | |
177 | | - | |
178 | | - | |
| 191 | + | |
| 192 | + | |
179 | 193 | | |
180 | 194 | | |
181 | 195 | | |
182 | | - | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
183 | 232 | | |
184 | | - | |
| 233 | + | |
185 | 234 | | |
186 | 235 | | |
187 | 236 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
| 20 | + | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| |||
312 | 312 | | |
313 | 313 | | |
314 | 314 | | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
315 | 321 | | |
316 | 322 | | |
317 | 323 | | |
| |||
564 | 570 | | |
565 | 571 | | |
566 | 572 | | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
567 | 620 | | |
568 | 621 | | |
569 | 622 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
0 commit comments