Skip to content

Auto-port 5.0: Eliminate redundant bounds checks in CompositeByteBuf accessors#16534

Merged
normanmaurer merged 1 commit into5.0from
auto-port-pr-16525-to-5.0
Mar 24, 2026
Merged

Auto-port 5.0: Eliminate redundant bounds checks in CompositeByteBuf accessors#16534
normanmaurer merged 1 commit into5.0from
auto-port-pr-16525-to-5.0

Conversation

@netty-project-bot
Copy link
Copy Markdown
Contributor

Auto-port of #16525 to 5.0
Cherry-picked commit: 6001499


Motivation:

Every _getXxx/_setXxx in CompositeByteBuf delegates to the underlying buffer's public API (e.g. c.buf.getByte()), which re-checks bounds that the composite level already validated.

Modifications:

  • Add an abuf field to Component that caches (AbstractByteBuf) buf at construction time, or null for non-AbstractByteBuf wrappers
  • Use abuf._getXxx() (no bounds check) when available, fall back to buf.getXxx() otherwise
  • Add sequentialReadBytes and sequentialGetBytes JMH benchmarks

Result:

Redundant bounds checks eliminated on the hot path.

Motivation:

Every _getXxx/_setXxx in CompositeByteBuf delegates to the underlying
buffer's public API (e.g. c.buf.getByte()), which re-checks bounds that
the composite level already validated.

Modifications:

- Add an `abuf` field to Component that caches `(AbstractByteBuf) buf`
at construction time, or null for non-AbstractByteBuf wrappers
- Use abuf._getXxx() (no bounds check) when available, fall back to
buf.getXxx() otherwise
- Add sequentialReadBytes and sequentialGetBytes JMH benchmarks

Result:

Redundant bounds checks eliminated on the hot path.

(cherry picked from commit 6001499)
@normanmaurer normanmaurer merged commit 621b359 into 5.0 Mar 24, 2026
12 of 13 checks passed
@normanmaurer normanmaurer deleted the auto-port-pr-16525-to-5.0 branch March 24, 2026 16:14
@normanmaurer normanmaurer added this to the 5.0.0.Final milestone Mar 24, 2026
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