Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

router: Optimize pruning zombie channels. #2799

Closed

Conversation

roeierez
Copy link
Contributor

This commit introduces a different, more optimized, approach to prune zombie channels.
"zombie channels" stands for channels that their last channel policy update time was earlier than "channel expiry", configured by default to a period of 14 days.
The current approach iterates all channels in the graph in order to filter those in need. This approach is time consuming, several seconds on my mobile device for ~40,000 channels, while during this time the
db is locked in a transaction.

The proposed change is to use an existing functionality that utilize the fact that channel update are saved indexed by date. This way enables us to go over only a small subset of the channels, only those that were updated before the "channel expiry" time and further filter them for our need.
The same graph that took several seconds to prune was pruned, after the change in several milliseconds.

Currently the pruneZombieChans is running every hour, I think that the performance improvement will safely allow to run it on every restart and make sure LND starts up with no zombie channels.

My measurements for ~40,000 channels.

Samsung galaxy s7
prune time before change: 5-12 seconds, depends on the current load.
prune time after change: 15 milliseconds.

Mac book pro 2.8 GHz Intel Core i7
prune time before change: ~400 milliseconds
prune time after change: 15 milliseconds.

This commit introduces a different, more optimized, appraoch to prune
zombie channels.
"zombie channels" stands for channels that their last channel policy
was update time was earlier than "channe expiry", configured by default
to a period of 14 days.
The current approach iterates all channels in the graph in order to
filter those in need. This approach is time consuming, several seconds
on my mobile device for ~40,000 channels, while during this time the
db is locked in a transaction.

The proposed change is to use an existing functionality that utilize the
fact that channel update are saved indexed by date. This method enables
us to go over only a small subset of the channels, only those that
were updated before the "channel expiry" time and further filter
them for our need.
The same graph that took several seconds to prune was pruned, after
the change in several milliseconds.
@halseth halseth requested a review from wpaulino March 19, 2019 12:37
@halseth
Copy link
Contributor

halseth commented Mar 19, 2019

Related: #2777

@Roasbeef Roasbeef added database Related to the database/storage of LND optimization P3 might get fixed, nice to have labels Apr 20, 2019
@roeierez
Copy link
Contributor Author

Replaced by #3197

@roeierez roeierez closed this Jun 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
database Related to the database/storage of LND optimization P3 might get fixed, nice to have
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants