Commit cc028f4
committed
Speed up
During startup, the lightning protocol forces us to fetch a ton of
gossip for channels where there is a `channel_update` in only one
direction. We then have to wait around a while until we can prune
the crap cause we don't know when the gossip sync has completed.
Sadly, doing a large prune via `remove_stale_channels_and_tracking`
is somewhat slow. Removing a large portion of our graph currently
takes a bit more than 7.5 seconds on an i9-14900K, which can
ultimately ~hang a node with a few less GHz ~forever.
The bulk of this time is in our `IndexedMap` removals, where we
walk the entire `keys` `Vec` to remove the entry, then shift it
down after removing.
Here we shift to a bulk removal model when removing channels, doing
a single `Vec` iterate + shift. This reduces the same test to
around 1.38 seconds on the same hardware.remove_stale_channels_and_tracking nontrivially1 parent c71334e commit cc028f4
2 files changed
+20
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2356 | 2356 | | |
2357 | 2357 | | |
2358 | 2358 | | |
2359 | | - | |
2360 | | - | |
2361 | | - | |
| 2359 | + | |
2362 | 2360 | | |
2363 | 2361 | | |
2364 | 2362 | | |
| |||
2382 | 2380 | | |
2383 | 2381 | | |
2384 | 2382 | | |
2385 | | - | |
| 2383 | + | |
2386 | 2384 | | |
2387 | 2385 | | |
2388 | 2386 | | |
2389 | 2387 | | |
2390 | 2388 | | |
2391 | | - | |
2392 | | - | |
2393 | | - | |
2394 | | - | |
| 2389 | + | |
| 2390 | + | |
| 2391 | + | |
| 2392 | + | |
| 2393 | + | |
2395 | 2394 | | |
2396 | | - | |
| 2395 | + | |
2397 | 2396 | | |
2398 | 2397 | | |
2399 | 2398 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
75 | 87 | | |
76 | 88 | | |
77 | 89 | | |
| |||
0 commit comments