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.

@tnull tnull self-assigned this Apr 16, 2026
@tnull tnull moved this to Goal: Merge in Weekly Goals Apr 16, 2026
@ldk-reviews-bot
Copy link
Copy Markdown

🔔 1st Reminder

Hey @joostjager! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Goal: Merge

Development

Successfully merging this pull request may close these issues.

2 participants