Commit bba5db3
committed
Correctly reuse storage with SubArrays
The definition of IntVector caused an implicit copy to convert SA to a
Vector{Int}, negating the efforts to reuse memory. Replace it with @view to get
reasonable memory consumption.
Suffing sorting a 100 MiB UInt8 array (an aarch64 executable):
before fix 10.324155 seconds (75 allocations: 16.797 GiB, 1.12% gc time)
after fix 8.059011 seconds (26 allocations: 400.007 MiB, 0.00% gc time)
Comparison with a few commonly-used suffix sorting libraries:
libsais 7.563240 seconds (3 allocations: 400.000 MiB, 0.00% gc time)
divsufsort 4.244779 seconds (3 allocations: 400.000 MiB, 0.00% gc time)1 parent 5ea45d8 commit bba5db3
2 files changed
+27
-30
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
| 27 | + | |
40 | 28 | | |
41 | 29 | | |
42 | 30 | | |
| |||
45 | 33 | | |
46 | 34 | | |
47 | 35 | | |
48 | | - | |
| 36 | + | |
49 | 37 | | |
50 | 38 | | |
51 | 39 | | |
| |||
71 | 59 | | |
72 | 60 | | |
73 | 61 | | |
74 | | - | |
| 62 | + | |
75 | 63 | | |
76 | | - | |
| 64 | + | |
77 | 65 | | |
78 | 66 | | |
79 | | - | |
| 67 | + | |
80 | 68 | | |
81 | 69 | | |
82 | 70 | | |
83 | | - | |
| 71 | + | |
84 | 72 | | |
85 | | - | |
| 73 | + | |
86 | 74 | | |
87 | 75 | | |
88 | | - | |
| 76 | + | |
89 | 77 | | |
90 | 78 | | |
91 | 79 | | |
92 | 80 | | |
93 | 81 | | |
94 | 82 | | |
95 | | - | |
| 83 | + | |
96 | 84 | | |
97 | 85 | | |
98 | 86 | | |
| |||
156 | 144 | | |
157 | 145 | | |
158 | 146 | | |
159 | | - | |
| 147 | + | |
160 | 148 | | |
161 | 149 | | |
162 | 150 | | |
| |||
183 | 171 | | |
184 | 172 | | |
185 | 173 | | |
186 | | - | |
| 174 | + | |
187 | 175 | | |
188 | 176 | | |
189 | | - | |
| 177 | + | |
190 | 178 | | |
191 | 179 | | |
192 | 180 | | |
| |||
231 | 219 | | |
232 | 220 | | |
233 | 221 | | |
234 | | - | |
235 | | - | |
| 222 | + | |
| 223 | + | |
236 | 224 | | |
237 | 225 | | |
238 | 226 | | |
| |||
345 | 333 | | |
346 | 334 | | |
347 | 335 | | |
348 | | - | |
349 | | - | |
| 336 | + | |
| 337 | + | |
350 | 338 | | |
351 | 339 | | |
352 | 340 | | |
| |||
395 | 383 | | |
396 | 384 | | |
397 | 385 | | |
398 | | - | |
399 | | - | |
| 386 | + | |
| 387 | + | |
400 | 388 | | |
401 | 389 | | |
402 | 390 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
184 | 184 | | |
185 | 185 | | |
186 | 186 | | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
0 commit comments