Automatic managed-ledger offload triggers create redundant retry work Coalesce automatic…
- User
Automatic managed-ledger offload triggers create redundant retry work
Coalesce automatic offload triggers while an automatic offload is running. There must be at most one active automatic run and at most one follow-up run when additional triggers arrive. A follow-up must still process newly eligible ledgers, and explicit/manual offload futures must retain their existing behavior.
Interface
No new public interfaces are introduced.
- Assistant
I'll search the codebase for managed-ledger automatic offload trigger handling and how retries are scheduled.
- Assistant
Running existing offload tests to establish a baseline, then implementing coalescing.
- Assistant
Implementing coalescing logic in
ManagedLedgerImpl. - Assistant
Automatic managed-ledger offload triggers are now coalesced in
ManagedLedgerImpl.Problem
Each automatic trigger that couldn't acquire
offloadMutexscheduled its own 100ms retry viamaybeOffloadInBackground. During a long offload (or while manual offload held the lock), many ledger rolls could queue many redundant retries.Solution
Automatic triggers are coalesced into at most one follow-up run:
requestCoalescedAutomaticOffload— When the mutex is busy, the trigger's promise is queued. Only one delayed follow-up task is scheduled.runCoalescedAutomaticOffloadIfNeeded— Runs when an automatic offload finishes (or when the delayed task fires). It drains all pending promises into a single combined future and starts one pass.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.