AI-generated analysisPublished automatically and not human-verified. Validated context appears in community notes below.
← Watch feed
Informational 20 Bitcoin

Speed up `remove_stale_channels_and_tracking` nontrivially

Public commit record

What the developer wrote

Authored by Matt Corallo

73/100 · Adequate
Speed up `remove_stale_channels_and_tracking` nontrivially

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.
✓ Specific, descriptive subject✓ Provides detailed explanatory context✓ Mentions testing or verification
The short version

What changed, and why it matters

This commit is a performance optimization, not a security fix. It speeds up a startup cleanup routine in the Lightning routing code by removing many stale channels in one pass instead of one at a time. The change reduces a reported 7.5-second freeze to about 1.4 seconds on a high-end CPU. There is no indication it fixes a vulnerability or changes security behavior.

Recommended action

No security action required. Treat as a normal performance improvement during review/merge.

Security signals we found

No strong security signals were identified.

Risk score

Why this scored 20/100

Our methodology →
Potential impact 2/30
Exploitability 0/25
Stealth signal 0/15
Affected reach 5/15
Confidence 9/10
Evidence quality 4/5
Human-validated context

Community notes

Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.

No validated notes yet.

The AI analysis stands alone for now. Submit a note if you can add evidence or important context.