Skip to content

Yield instead of Task.Delay when AOF BulkConsume throttle is zero#1940

Merged
vazois merged 3 commits into
mainfrom
vazois/aof-bulk-consume-delay
Jul 16, 2026
Merged

Yield instead of Task.Delay when AOF BulkConsume throttle is zero#1940
vazois merged 3 commits into
mainfrom
vazois/aof-bulk-consume-delay

Conversation

@vazois

@vazois vazois commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Avoid blocking for a full throttleMs interval in BulkConsume when the throttle duration is zero. When throttleMs == 0, yield the thread (await Task.Yield()) instead of await Task.Delay(0) while waiting for the next record.

Also makes TryBulkConsumeNext private.

Closes #1939

Copilot AI review requested due to automatic review settings July 16, 2026 18:00

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates TsavoriteLogScanIterator.BulkConsumeAllAsync to avoid a no-op Task.Delay(0) loop when throttleMs == 0, and tightens encapsulation by making TryBulkConsumeNext private.

Changes:

  • Replace await Task.Delay(0, token)-style waiting with a Task.Yield() path when throttleMs == 0.
  • Keep Task.Delay(throttleMs, token) for non-zero throttling.
  • Change TryBulkConsumeNext visibility from public to private.

@vazois vazois self-assigned this Jul 16, 2026
@vazois vazois merged commit 46786d9 into main Jul 16, 2026
210 of 211 checks passed
@vazois vazois deleted the vazois/aof-bulk-consume-delay branch July 16, 2026 23:16
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.

3 participants