Skip to content

Simple bkpr speedups#8657

Merged
rustyrussell merged 2 commits intoElementsProject:masterfrom
rustyrussell:guilt/simple-bkpr-speedups
Nov 4, 2025
Merged

Simple bkpr speedups#8657
rustyrussell merged 2 commits intoElementsProject:masterfrom
rustyrussell:guilt/simple-bkpr-speedups

Conversation

@rustyrussell
Copy link
Contributor

These are two fairly simple speedup which help large nodes with bookkeeper. We've got other work for general speedups this release, but these two make a big difference to the previous release, so this is a separate PR.

  1. Reduce all those DEBUG level logs which bookkeeper creates on every channelmoves entry: we now do 3 messages instead of 1000 on each run.
  2. We lazily create sql indexes, which speeds up initial load after restart (82 seconds to 17 seconds)

Since we're synchronous, these only reach lightningd after we're done:
in the case of 1.6M channelmoves, that can give it major heartburn.

In practice, this reduces the first bkpr command on a fresh upgrade
from 349 to 235 seconds (but this was before other improvements we did
this release).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Changed: Plugins: `bookkeeper` reduced logging for large imports to increase speed.
This makes a big difference for large tables.  Consider 1.6M channelmoves,
which took 82 seconds to populate, now takes 17 seconds:

Before:
	plugin-sql: Time to call listchannelmoves: 10.380341485 seconds
	plugin-sql: Time to refresh channelmoves: 82.311287310 seconds

After:

	plugin-sql: Time to call listchannelmoves: 9.962815480 seconds
	plugin-sql: Time to refresh channelmoves: 15.711549299 seconds
	plugin-sql: Time to refresh + create indices for channelmoves: 17.100151235 seconds

tests/test_coinmoves.py::test_generate_coinmoves (50,000):
	Time (from start to end of l2 node):	27 seconds
	Worst latency:				16.0 seconds

Changelog-Changed: Plugins: `sql` initial load for tables is much faster (e.g 82 to 17 seconds for very large channelmoves table).
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
@rustyrussell rustyrussell added this to the v25.12 milestone Nov 4, 2025
@rustyrussell rustyrussell requested a review from sangbida November 4, 2025 00:37
Copy link
Collaborator

@sangbida sangbida left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is awesome :)

@rustyrussell rustyrussell merged commit fc2fb7c into ElementsProject:master Nov 4, 2025
38 of 39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants