Commit 01bb51b
authored
perf: Memory optimization for RangeCache (#65)
Motivation
Currently, RangeCache will implicitly retain a reference to the RangeResponse KeyValue arrays used to initially populate/refresh the cache via the promise held in its startFuture field.
This ref is there only to propagate cancellation to the etcd range request but can take up significant memory once completed if the cache is large.
Note this is mostly the size of the object array itself since the contained objects will usually be referenced from the cache's map. However over time unnecessary references could remain if/when the corresponding KeyValues are deleted. The array's "shallow" footprint might also be non-negligible for very large caches.
Modifications
- Change the promise used for the start future to hold an explicit reference to the range request future, so that it can be nulled as soon as that other future completes.
- Remove an incorrect assertion
- Clean up a weird @nullable import1 parent 6ab55c0 commit 01bb51b
1 file changed
Lines changed: 31 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
47 | | - | |
48 | 47 | | |
49 | 48 | | |
50 | 49 | | |
51 | 50 | | |
52 | 51 | | |
53 | 52 | | |
54 | 53 | | |
55 | | - | |
56 | 54 | | |
57 | 55 | | |
58 | 56 | | |
| |||
210 | 208 | | |
211 | 209 | | |
212 | 210 | | |
213 | | - | |
214 | | - | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
215 | 220 | | |
216 | | - | |
217 | | - | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
218 | 236 | | |
219 | 237 | | |
220 | 238 | | |
221 | 239 | | |
222 | 240 | | |
| 241 | + | |
223 | 242 | | |
224 | 243 | | |
225 | 244 | | |
226 | 245 | | |
227 | 246 | | |
228 | | - | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
229 | 251 | | |
230 | 252 | | |
231 | 253 | | |
| |||
323 | 345 | | |
324 | 346 | | |
325 | 347 | | |
326 | | - | |
327 | 348 | | |
328 | 349 | | |
329 | 350 | | |
| |||
651 | 672 | | |
652 | 673 | | |
653 | 674 | | |
654 | | - | |
| 675 | + | |
655 | 676 | | |
656 | 677 | | |
657 | 678 | | |
| |||
1020 | 1041 | | |
1021 | 1042 | | |
1022 | 1043 | | |
1023 | | - | |
| 1044 | + | |
1024 | 1045 | | |
1025 | 1046 | | |
1026 | 1047 | | |
| |||
0 commit comments