Skip to content

(2.14) [IMPROVED] Only allocate AckAll sequences when acking in place - #8528

Merged
neilalexander merged 1 commit into
mainfrom
maurice/ack-all-alloc
Aug 27, 2026
Merged

(2.14) [IMPROVED] Only allocate AckAll sequences when acking in place#8528
neilalexander merged 1 commit into
mainfrom
maurice/ack-all-alloc

Conversation

@MauriceVanVeen

Copy link
Copy Markdown
Member

Follow-up of #8431

Signed-off-by: Maurice van Veen <github@mauricevanveen.com>
@MauriceVanVeen
MauriceVanVeen requested a review from a team as a code owner August 27, 2026 07:47
@MauriceVanVeen MauriceVanVeen changed the title [IMPROVED] Only allocate AckAll sequences when acking in place (2.14) [IMPROVED] Only allocate AckAll sequences when acking in place Aug 27, 2026
@synadia-claude-reviewer

synadia-claude-reviewer Bot commented Aug 27, 2026

Copy link
Copy Markdown

Claude finished @MauriceVanVeen's task in 1m 5s —— View job


Code Review

  • Gather PR diff and context
  • Review changed code in server/consumer.go
  • Verify correctness of guard condition
  • Post findings

Summary

Clean, correct optimization. The change guards the ackAllSeqs slice allocation behind if ackInPlace, preventing a heap allocation that was always wasted when ackInPlace == false.

Why it's safe:

All uses of ackAllSeqs were already gated on ackInPlace:

  1. Write path (server/consumer.go:3823): if ackInPlace && seq != sseq { ackAllSeqs = append(...) } — the slice is never written unless ackInPlace is true.
  2. Read path (server/consumer.go:3859-3863): if ackInPlace { for _, seq := range ackAllSeqs { ... } } — the slice is never iterated unless ackInPlace is true.

So before this fix, make([]uint64, 0, ...) was called unconditionally for every AckAll/AckFlowControl ack, but the resulting slice was immediately discarded whenever ackInPlace == false (i.e., for all clustered consumers or LimitsPolicy retention). This is the hot path for cumulative acknowledgment — skipping the allocation is a meaningful win.

Capacity bound is sound: sgap = sseq - o.asflr. The early sseq <= o.asflr check at line 3804 guarantees sgap >= 1, so sgap - 1 >= 0 — no underflow.

No issues found. LGTM.

@neilalexander neilalexander left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@neilalexander
neilalexander merged commit 6fb4c19 into main Aug 27, 2026
52 checks passed
@neilalexander
neilalexander deleted the maurice/ack-all-alloc branch August 27, 2026 08:52
neilalexander added a commit that referenced this pull request Aug 27, 2026
Includes the following:

- #8431
- #8528
- #8527
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