Skip to content

DRY up batched KVStore reads with semaphore-based BatchingStore#876

Open
tnull wants to merge 1 commit intolightningdevkit:mainfrom
tnull:2026-04-batching-store
Open

DRY up batched KVStore reads with semaphore-based BatchingStore#876
tnull wants to merge 1 commit intolightningdevkit:mainfrom
tnull:2026-04-batching-store

Conversation

@tnull
Copy link
Copy Markdown
Collaborator

@tnull tnull commented Apr 15, 2026

Introduce BatchingStore, a KVStore wrapper that limits concurrent async I/O via a tokio::sync::Semaphore. During initialization the builder wraps the store in BatchingStore so all parallel reads share a single concurrency cap, rather than each reader maintaining its own JoinSet-based batch queue.

Replace the duplicated ~75-line batching loops in read_payments and read_pending_payments with a generic read_all_objects<T: Readable> helper that spawns all reads into a JoinSet (relying on the store wrapper for throttling) and collects deserialized results. Both functions become thin one-line delegations.

Co-Authored-By: HAL 9000

Introduce `BatchingStore`, a `KVStore` wrapper that limits concurrent
async I/O via a `tokio::sync::Semaphore`. During initialization the
builder wraps the store in `BatchingStore` so all parallel reads share
a single concurrency cap, rather than each reader maintaining its own
`JoinSet`-based batch queue.

Replace the duplicated ~75-line batching loops in `read_payments` and
`read_pending_payments` with a generic `read_all_objects<T: Readable>`
helper that spawns all reads into a `JoinSet` (relying on the store
wrapper for throttling) and collects deserialized results. Both
functions become thin one-line delegations.

Co-Authored-By: HAL 9000
@tnull tnull requested a review from joostjager April 15, 2026 13:54
@ldk-reviews-bot
Copy link
Copy Markdown

ldk-reviews-bot commented Apr 15, 2026

👋 Thanks for assigning @joostjager as a reviewer!
I'll wait for their review and will help manage the review process.
Once they submit their review, I'll check if a second reviewer would be helpful.

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