GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — JdkZlibDecoder: accumulate decompressed output before firing channelRead by franz1981 · Pull Request #16510 · netty/netty

Conversation

@franz1981

@franz1981 franz1981 commented Mar 17, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Motivation:

A recent change (9d804c5) changed JdkZlibDecoder to fire
ctx.fireChannelRead() on every inflate iteration (~8KB output) when
maxAllocation is 0. For a typical ~150KB HTTP response this produces
~19 small buffer allocations and ~19 pipeline dispatches through the
internal EmbeddedChannel used by HttpContentDecoder, causing a 30-35%
throughput regression even in aggregated mode (where chunk count is
irrelevant downstream).

Modifications:

Accumulate decompressed output up to 64KB (DEFAULT_MAX_FORWARD_BYTES)
before firing ctx.fireChannelRead(). The buffer grows naturally via
prepareDecompressBuffer() until the threshold, then fires and starts a
new buffer. Any remaining data fires in the finally block as before.

Memory per in-flight buffer is bounded to 64KB regardless of the
compressed input size.

Result:

Throughput is restored to pre-regression levels. Chunks per response
drop from ~163 to ~6 for a 150KB payload.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@franz1981
franz1981 requested a review from normanmaurer March 17, 2026 17:25
@franz1981 franz1981 assigned yawkat Mar 17, 2026
@franz1981
franz1981 force-pushed the 4.2_batch_decompressed_chunks branch from 648028b to 6b9a45f Compare March 17, 2026 17:26
@franz1981 franz1981 mentioned this pull request Mar 17, 2026
Severe throughput regression after upgrading Netty from 4.1.124.Final to 4.1.125.Final #15852
Closed
@normanmaurer
normanmaurer requested review from chrisvest and yawkat March 17, 2026 17:31
@franz1981

franz1981 commented Mar 17, 2026

Copy link
Copy Markdown
Contributor Author

@normanmaurer I'm still checking how to expose it for "expert" users: any suggestion @yawkat ? @vietj ?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@franz1981
franz1981 marked this pull request as draft March 17, 2026 17:43
@franz1981

franz1981 commented Mar 17, 2026

Copy link
Copy Markdown
Contributor Author

I'm running some benchmark to make sure is not regressing in any form

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@franz1981

franz1981 commented Mar 17, 2026

Copy link
Copy Markdown
Contributor Author

The reproducer from @wbabyte is not passing as good as before the zip bomb changes, because the composite buffer is very bad with single byte access 😢 @chrisvest

Which means:

  • we have to fix composite buffers for adaptive as a separate commit or
  • we consolidate with a single buffer for this pr

wdyt @normanmaurer ?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@yawkat

yawkat commented Mar 17, 2026

Copy link
Copy Markdown
Contributor

@franz1981 there's #16076 … I think we need a new approach to composite buffer use cases, which sits somewhere between the large flat buffers and fragmented composite buffers

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@franz1981

franz1981 commented Mar 17, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

yeah so, moving to copying into a single flat buffer proved to be enough to fix the issue on the reproducer

  ┌───────────────────────────────────┬────────────┬──────────────────┬─────────────┐
  │              Version              │ Chunks/Req │ Throughput (RPS) │ P50 Latency │
  ├───────────────────────────────────┼────────────┼──────────────────┼─────────────┤
  │ Pre-zipbomb (4.2.5-SNAPSHOT)      │ 3.00       │ 5,391            │ 7.75ms      │
  ├───────────────────────────────────┼────────────┼──────────────────┼─────────────┤
  │ Broken (4.2.10)                   │ 163.06     │ 5,399-5,527      │ 7.75ms      │
  ├───────────────────────────────────┼────────────┼──────────────────┼─────────────┤
  │ Fix v1 (CompositeByteBuf)         │ 3.00       │ 4,078-4,248      │ 10.19ms     │
  ├───────────────────────────────────┼────────────┼──────────────────┼─────────────┤
  │ Fix v3 (heapBuffer consolidation) │ 3.00       │ 5,435            │ 7.77ms      │
  └───────────────────────────────────┴────────────┴──────────────────┴─────────────┘

where Fix v1 is what we got in this pr and the heapBuffer consolidation uses a single heap buffer (to match the input ones).
The reason for using an heap one is due to FFM overhead: Using direct buffers for downstream reads adds MemorySessionImpl.checkValidStateRaw overhead which heap-ones doesn't have @yawkat

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@chrisvest

chrisvest commented Mar 18, 2026

Copy link
Copy Markdown
Member

Sounds like a cumulation strategy, basically.

I think this could also be done as a separate read consolidation handler?

we have to fix composite buffers for adaptive as a separate commit

What do you mean by this? I don't see how adaptive is different in this regard from the other allocators.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@franz1981

franz1981 commented Mar 18, 2026

Copy link
Copy Markdown
Contributor Author

@chrisvest

Sounds like a cumulation strategy, basically.

Yes, it effectively is!

I think this could also be done as a separate read consolidation handler?

It could, but the batching needs to be aware of the decode boundaries — we must flush after each writeInbound + finish call to avoid delaying content delivery.
A generic handler downstream wouldn't know when a decode unit ends: keeping it in ByteBufForwarder seems more natural to me ^^

What do you mean by this? I don't see how adaptive is different in this regard from the other allocators.

You're right to challenge that — I was wrong. The issue I observed was about CompositeByteBuf random-access performance (findComponent per getByte) and JDK 21+ direct buffer FFM overhead (MemorySessionImpl.checkValidStateRaw), neither of which is specific to the adaptive allocator.
I'm now changing the cumulation strategy to NOT use composite buffers due to this reason, but I still believe is something we should fix separately, as @yawkat suggested (e.g. streaming optimized use case?).

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@franz1981
franz1981 force-pushed the 4.2_batch_decompressed_chunks branch from 6b9a45f to 6a2e2ee Compare March 18, 2026 06:11
@franz1981
franz1981 marked this pull request as ready for review March 18, 2026 06:11
franz1981
franz1981 commented Mar 18, 2026
View reviewed changes
Comment thread codec-http/src/main/java/io/netty/handler/codec/http/HttpContentDecoder.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

franz1981
franz1981 commented Mar 18, 2026
View reviewed changes
Comment thread codec-http/src/main/java/io/netty/handler/codec/http/HttpContentDecoder.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

@franz1981
franz1981 force-pushed the 4.2_batch_decompressed_chunks branch 4 times, most recently from 6b96bc1 to dc3b872 Compare March 18, 2026 06:29
@franz1981

franz1981 commented Mar 18, 2026

Copy link
Copy Markdown
Contributor Author

Updated figures

  ┌───────────────────────────────┬────────┬────────────────┐                                                                                                           
  │            Version            │  RPS   │ Chunks/Request │     
  ├───────────────────────────────┼────────┼────────────────┤                                                                                                           
  │ Pre-zipbomb (4.2.5-SNAPSHOT)  │ ~5,400 │ 3              │     
  ├───────────────────────────────┼────────┼────────────────┤
  │ Broken (4.2.10, post-zipbomb) │ ~5,200 │ 163            │
  ├───────────────────────────────┼────────┼────────────────┤
  │ Fixed (16KB batch)            │ ~5,507 │ 21             │
  └───────────────────────────────┴────────┴────────────────┘

@wbabyte can you check if it works for you?
I've been conservative with the accumulation here ^^

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@franz1981
franz1981 force-pushed the 4.2_batch_decompressed_chunks branch from dc3b872 to e978307 Compare March 18, 2026 09:18
@wbabyte

wbabyte commented Mar 18, 2026

Copy link
Copy Markdown

@franz1981 thank you for this. I can try it out, but do you have a build I can use?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

normanmaurer
normanmaurer requested changes Mar 18, 2026
View reviewed changes
Comment thread codec-http/src/main/java/io/netty/handler/codec/http/HttpContentDecoder.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread codec-http/src/main/java/io/netty/handler/codec/http/HttpContentDecoder.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread codec-http/src/main/java/io/netty/handler/codec/http/HttpContentDecoder.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread codec-http/src/test/java/io/netty/handler/codec/http/ExcessiveChunksTest.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

@franz1981

franz1981 commented Mar 18, 2026

Copy link
Copy Markdown
Contributor Author

@wbabyte I think you should build (clean install) it from this branch PR and set in your reproducer a snapshot release 🙏

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@franz1981
franz1981 force-pushed the 4.2_batch_decompressed_chunks branch from e978307 to 8e79ccd Compare March 18, 2026 09:41
franz1981
franz1981 commented Mar 18, 2026
View reviewed changes
Comment thread codec-http/src/main/java/io/netty/handler/codec/http/HttpContentDecompressor.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

@franz1981
franz1981 force-pushed the 4.2_batch_decompressed_chunks branch from 8e79ccd to 2326755 Compare March 18, 2026 09:44
yawkat
yawkat approved these changes Mar 20, 2026
View reviewed changes
@franz1981

franz1981 commented Mar 20, 2026

Copy link
Copy Markdown
Contributor Author

I would backport this to 4.1 as well, wdyt? @normanmaurer @yawkat
As the "guilty" commit which caused this is there too

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@yawkat

yawkat commented Mar 20, 2026

Copy link
Copy Markdown
Contributor

We already had people complain with the original change which did the opposite thing (more fragmentation), so I'm not sure backporting is a good idea.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@franz1981

franz1981 commented Mar 20, 2026

Copy link
Copy Markdown
Contributor Author

But this would leave 4.1 users with the performance degradation...?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@normanmaurer

normanmaurer commented Mar 20, 2026

Copy link
Copy Markdown
Member

@yawkat I think backporting makes sense in this case /cc @chrisvest

yawkat reacted with thumbs up emoji franz1981 reacted with rocket emoji
All reactions
  • 👍 1 reaction
  • 🚀 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@normanmaurer normanmaurer added this to the 4.2.11.Final milestone Mar 20, 2026
@franz1981 franz1981 added the needs_backport label Mar 23, 2026
@franz1981
addressing Norman's comment
2a1a3be
@franz1981

franz1981 commented Mar 23, 2026

Copy link
Copy Markdown
Contributor Author

PTAL @normanmaurer I've addressed #16510 (comment)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@chrisvest chrisvest added needs-cherry-pick-4.1 This PR should be cherry-picked to 4.1 once merged. needs-cherry-pick-5.0 This PR should be cherry-picked to 5.0 once merged. and removed needs_backport labels Mar 23, 2026
chrisvest
chrisvest approved these changes Mar 23, 2026
View reviewed changes
@normanmaurer

normanmaurer commented Mar 23, 2026

Copy link
Copy Markdown
Member

@chrisvest do you agree that we should also port this to 4.1 ?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@chrisvest

chrisvest commented Mar 23, 2026

Copy link
Copy Markdown
Member

@normanmaurer I'm not too strongly opinionated on it, but I think it makes sense to backport if its not too much trouble.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

normanmaurer
normanmaurer approved these changes Mar 24, 2026
View reviewed changes
@normanmaurer
normanmaurer merged commit a7fbb6f into netty:4.2 Mar 24, 2026
22 of 23 checks passed

Uh oh!

There was an error while loading. Please reload this page.

netty-project-bot pushed a commit that referenced this pull request Mar 24, 2026
@franz1981 @netty-project-bot
JdkZlibDecoder: accumulate decompressed output before firing channelR…
d38bbed
…ead (#16510)

Motivation:

A recent change (9d804c5) changed
JdkZlibDecoder to fire
ctx.fireChannelRead() on every inflate iteration (~8KB output) when
maxAllocation is 0. For a typical ~150KB HTTP response this produces
~19 small buffer allocations and ~19 pipeline dispatches through the
internal EmbeddedChannel used by HttpContentDecoder, causing a 30-35%
throughput regression even in aggregated mode (where chunk count is
irrelevant downstream).

Modifications:

Accumulate decompressed output up to 64KB (DEFAULT_MAX_FORWARD_BYTES)
before firing ctx.fireChannelRead(). The buffer grows naturally via
prepareDecompressBuffer() until the threshold, then fires and starts a
new buffer. Any remaining data fires in the finally block as before.

Memory per in-flight buffer is bounded to 64KB regardless of the
compressed input size.

Result:

Throughput is restored to pre-regression levels. Chunks per response
drop from ~163 to ~6 for a 150KB payload.

(cherry picked from commit a7fbb6f)
@netty-project-bot

netty-project-bot commented Mar 24, 2026

Copy link
Copy Markdown
Contributor

Auto-port PR for 4.1: #16532

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

netty-project-bot pushed a commit that referenced this pull request Mar 24, 2026
@franz1981 @netty-project-bot
JdkZlibDecoder: accumulate decompressed output before firing channelR…
4012644
…ead (#16510)

Motivation:

A recent change (9d804c5) changed
JdkZlibDecoder to fire
ctx.fireChannelRead() on every inflate iteration (~8KB output) when
maxAllocation is 0. For a typical ~150KB HTTP response this produces
~19 small buffer allocations and ~19 pipeline dispatches through the
internal EmbeddedChannel used by HttpContentDecoder, causing a 30-35%
throughput regression even in aggregated mode (where chunk count is
irrelevant downstream).

Modifications:

Accumulate decompressed output up to 64KB (DEFAULT_MAX_FORWARD_BYTES)
before firing ctx.fireChannelRead(). The buffer grows naturally via
prepareDecompressBuffer() until the threshold, then fires and starts a
new buffer. Any remaining data fires in the finally block as before.

Memory per in-flight buffer is bounded to 64KB regardless of the
compressed input size.

Result:

Throughput is restored to pre-regression levels. Chunks per response
drop from ~163 to ~6 for a 150KB payload.

(cherry picked from commit a7fbb6f)
@netty-project-bot

netty-project-bot commented Mar 24, 2026

Copy link
Copy Markdown
Contributor

Auto-port PR for 5.0: #16533

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot removed the needs-cherry-pick-4.1 This PR should be cherry-picked to 4.1 once merged. label Mar 24, 2026
This was referenced Mar 24, 2026
Auto-port 4.1: JdkZlibDecoder: accumulate decompressed output before firing channelRead #16532
Merged
Auto-port 5.0: JdkZlibDecoder: accumulate decompressed output before firing channelRead #16533
Merged
@github-actions github-actions Bot removed the needs-cherry-pick-5.0 This PR should be cherry-picked to 5.0 once merged. label Mar 24, 2026
normanmaurer pushed a commit that referenced this pull request Mar 24, 2026
@netty-project-bot @franz1981
Auto-port 4.1: JdkZlibDecoder: accumulate decompressed output before …
10c1603
…firing channelRead (#16532)

Auto-port of #16510 to 4.1
Cherry-picked commit: a7fbb6f

---
Motivation:

A recent change (9d804c5) changed
JdkZlibDecoder to fire
ctx.fireChannelRead() on every inflate iteration (~8KB output) when
maxAllocation is 0. For a typical ~150KB HTTP response this produces
~19 small buffer allocations and ~19 pipeline dispatches through the
internal EmbeddedChannel used by HttpContentDecoder, causing a 30-35%
throughput regression even in aggregated mode (where chunk count is
irrelevant downstream).

Modifications:

Accumulate decompressed output up to 64KB (DEFAULT_MAX_FORWARD_BYTES)
before firing ctx.fireChannelRead(). The buffer grows naturally via
prepareDecompressBuffer() until the threshold, then fires and starts a
new buffer. Any remaining data fires in the finally block as before.

Memory per in-flight buffer is bounded to 64KB regardless of the
compressed input size.

Result:

Throughput is restored to pre-regression levels. Chunks per response
drop from ~163 to ~6 for a 150KB payload.

Co-authored-by: Francesco Nigro <[email protected]>
normanmaurer pushed a commit that referenced this pull request Mar 24, 2026
@netty-project-bot @franz1981
Auto-port 5.0: JdkZlibDecoder: accumulate decompressed output before …
4c5bb34
…firing channelRead (#16533)

Auto-port of #16510 to 5.0
Cherry-picked commit: a7fbb6f

---
Motivation:

A recent change (9d804c5) changed
JdkZlibDecoder to fire
ctx.fireChannelRead() on every inflate iteration (~8KB output) when
maxAllocation is 0. For a typical ~150KB HTTP response this produces
~19 small buffer allocations and ~19 pipeline dispatches through the
internal EmbeddedChannel used by HttpContentDecoder, causing a 30-35%
throughput regression even in aggregated mode (where chunk count is
irrelevant downstream).

Modifications:

Accumulate decompressed output up to 64KB (DEFAULT_MAX_FORWARD_BYTES)
before firing ctx.fireChannelRead(). The buffer grows naturally via
prepareDecompressBuffer() until the threshold, then fires and starts a
new buffer. Any remaining data fires in the finally block as before.

Memory per in-flight buffer is bounded to 64KB regardless of the
compressed input size.

Result:

Throughput is restored to pre-regression levels. Chunks per response
drop from ~163 to ~6 for a 150KB payload.

Co-authored-by: Francesco Nigro <[email protected]>
@franz1981 franz1981 mentioned this pull request Mar 25, 2026
Throughput regression with Vert.x 4.5.21 and Netty 4.1.125+ due to ZlibDecoder changes eclipse-vertx/vert.x#6024
Closed
@normanmaurer normanmaurer mentioned this pull request Oct 1, 2026
child5 #17695
Closed
@normanmaurer normanmaurer mentioned this pull request Oct 26, 2026
crisp nova cceda091 #18109
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@chrisvest chrisvest chrisvest approved these changes
@normanmaurer normanmaurer normanmaurer approved these changes
@yawkat yawkat yawkat approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@yawkat yawkat

Labels

None yet

Projects

None yet

Milestone

4.2.11.Final

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

7 participants

@franz1981 @yawkat @chrisvest @wbabyte @remibaptistegio @normanmaurer @netty-project-bot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.