Skip to content

Speed up producer batch acknowledgement tracking - #300

Open
davidthorne72 wants to merge 1 commit into
apache:masterfrom
davidthorne72:issue-298-batch-tracking-performance
Open

davidthorne72 wants to merge 1 commit into
apache:masterfrom
davidthorne72:issue-298-batch-tracking-performance

Conversation

@davidthorne72

Copy link
Copy Markdown

Partially addresses #298; complements the independent bulk-ACK correctness PR #299. Both branches are based directly on upstream master, and this PR does not depend on #299.

Description

Index outstanding producer batches by ledger, entry, and partition instead of searching a linked list under the receive/ACK lock. Track the number of unacknowledged indices alongside the bit array instead of rescanning every bit after each ACK. Remove completed batches by key, and retain partial ACK progress when an incomplete batch is redelivered.

The shared lock remains; the work performed while holding it is now constant-time on average per batched ID.

Regression

No release regression is established. New unit tests cover cross-ledger/partition identity, out-of-order and duplicate indices, incomplete and completed batch redelivery, clearing on seek, disabled tracking for readers, and concurrent completion. The incomplete-redelivery test fails on the original implementation because a duplicate tracking entry remains after the first completion.

Testing

  • Release build succeeds for netstandard2.0, netstandard2.1, net8.0, net9.0, and net10.0.
  • All 345 tests pass locally, including the Pulsar/Testcontainers integration suite.
  • Scoped dotnet format verification passes for the solution and the new benchmark project.
  • Added reproducible BenchmarkDotNet benchmarks. On .NET 10 / Apple M2 Pro, ShortRun comparisons against upstream master:
Scenario Before After
Partial ACK, 10,000 outstanding batches 52,940 ns 9.89 ns
Partial ACK, 1,000-message batch 618 ns 9.59 ns
Parallel ACKs and receive-queue polling, 1,000 outstanding batches 8.62 ms 0.134 ms

These are synthetic tracker benchmarks using a repeated partial-batch index; the parallel case polls an empty receive queue. They demonstrate scaling and reduced time holding the shared lock, not measured production throughput or a production contention percentage.

Index batches by ledger, entry, and partition and count remaining unacknowledged indices so ACKs no longer scan batches or bit arrays under the receive lock. Preserve partial progress on redelivery.

Add regression tests and repeatable lookup, batch-size, and concurrent ACK/receive benchmarks.

Refs apache#298

This branch has not been deployed

No deployments
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