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 — Make unpooled buffers avoid shared arenas by chrisvest · Pull Request #16443 · netty/netty

Conversation

@chrisvest

@chrisvest chrisvest commented Mar 12, 2026 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

Motivation:
Shared arenas can be expensive to close if we do it a lot, for instance in cases when we use the UnpooledByteBufAllocator.

Modification:
Make Unpooled buffers avoid shared arenas and instead fall back to GC/reference processing buffer cleaning. Make the pooling allocators explicitly state that they permit "expensive" clean operations to that they use shared arenas.

Result:
Greatly improves system-wide performance and scalability when allocating a lot of unpooled buffers, at the cost of delayed cleaning/deallocation and in turn higher memory usage.

This should also address a number of flaky test failures we see, that are caused by timeouts due to increased time we were spending in closing shared arenas.

If the use GC and reference counting causes adverse performance effects, e.g. performance regressions or poor GC behavior, then the previous behavior (letting unpooled buffers use shared memory segment arenas) can be restored by setting the io.netty.ignoreExpensiveClean=true system property.

Sorry, something went wrong.

Uh oh!

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

franz1981 and yawkat reacted with heart emoji
All reactions
  • ❤️ 2 reactions
@chrisvest
Make unpooled buffers avoid shared arenas
298177b
Motivation:
Shared arenas can be expensive to close if we do it a lot, for instance in cases when we use the UnpooledByteBufAllocator.

Modification:
Make Unpooled buffers avoid shared arenas and instead fall back to GC/reference processing buffer cleaning.
Make the pooling allocators explicitly state that they permit "expensive" clean operations to that they use shared arenas.

Result:
Greatly improves system-wide performance and scalability when allocating a lot of unpooled buffers, at the cost of delayed cleaning/deallocation and in turn higher memory usage.

This should also address a number of flaky test failures we see, that are caused by timeouts due to increased time we were spending in closing shared arenas.
@chrisvest chrisvest added this to the 4.2.11.Final milestone Mar 12, 2026
@chrisvest
chrisvest requested a review from normanmaurer March 12, 2026 17:42
@chrisvest chrisvest added the needs-cherry-pick-5.0 This PR should be cherry-picked to 5.0 once merged. label Mar 12, 2026
normanmaurer
normanmaurer approved these changes Mar 12, 2026
View reviewed changes
franz1981
franz1981 approved these changes Mar 12, 2026
View reviewed changes

@franz1981 franz1981 left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I have talked about this change already with Norman

Sorry, something went wrong.

Uh oh!

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

All reactions
franz1981
franz1981 approved these changes Mar 12, 2026
View reviewed changes

@franz1981 franz1981 left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I have talked about this change already with Norman

Sorry, something went wrong.

Uh oh!

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

chrisvest reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@chrisvest
Fix unpooled direct memory accounting
ee3f612
@chrisvest
chrisvest enabled auto-merge (squash) March 12, 2026 18:19
@chrisvest
Fix getting the memory address of direct unpooled buffers
e69824f
@chrisvest

chrisvest commented Mar 12, 2026

Copy link
Copy Markdown
Member Author

@franz1981 @normanmaurer It needed a few more compatibility fixes. Should work now.

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

Sorry, something went wrong.

Uh oh!

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

chrisvest added 2 commits March 12, 2026 13:17
@chrisvest
Merge branch '4.2' into 4.2-unpooled-direct-buf
2183f5c
@chrisvest
Fix checkstyle
d980874
normanmaurer
normanmaurer reviewed Mar 12, 2026
View reviewed changes
Comment thread common/src/main/java/io/netty/util/internal/Cleaner.java Resolved

Uh oh!

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

@chrisvest
chrisvest disabled auto-merge March 12, 2026 21:37
@chrisvest
Make Cleaner.hasExpensiveClean not a default-method
c847146
@chrisvest

chrisvest commented Mar 12, 2026

Copy link
Copy Markdown
Member Author

@normanmaurer Addressed your comment.

All reactions

Sorry, something went wrong.

Uh oh!

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

@chrisvest

chrisvest commented Mar 13, 2026

Copy link
Copy Markdown
Member Author

Hmm... I think we should also add a system property override, in case it causes adverse performance regressions for someone.

normanmaurer and franz1981 reacted with thumbs up emoji
All reactions
  • 👍 2 reactions

Sorry, something went wrong.

Uh oh!

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

normanmaurer
normanmaurer requested changes Mar 13, 2026
View reviewed changes

@normanmaurer normanmaurer left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

One nit....

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread buffer/src/main/java/io/netty/buffer/UnpooledDirectByteBuf.java Outdated
return PlatformDependent.allocateDirect(capacity, false);
}

protected CleanableDirectBuffer allocateDirectBuffer(int capacity, boolean permitExpensiveClean) {

@normanmaurer normanmaurer Mar 13, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

just make this private or package-private for now ?

Sorry, something went wrong.

Uh oh!

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

All reactions
@yawkat

yawkat commented Mar 13, 2026

Copy link
Copy Markdown
Contributor

this will make the graal team happy.

franz1981 reacted with heart emoji
All reactions
  • ❤️ 1 reaction

Sorry, something went wrong.

Uh oh!

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

@chrisvest
Address comments
ac2606f
@chrisvest

chrisvest commented Mar 13, 2026

Copy link
Copy Markdown
Member Author

@normanmaurer comments addressed.

All reactions

Sorry, something went wrong.

Uh oh!

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

normanmaurer
normanmaurer approved these changes Mar 14, 2026
View reviewed changes
@normanmaurer
normanmaurer merged commit c79ce23 into netty:4.2 Mar 14, 2026
34 of 35 checks passed

Uh oh!

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

@netty-project-bot

netty-project-bot commented Mar 14, 2026

Copy link
Copy Markdown
Contributor

Could not create auto-port PR.
Got conflicts when cherry-picking onto 5.0.

All reactions

Sorry, something went wrong.

Uh oh!

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

normanmaurer pushed a commit that referenced this pull request Mar 14, 2026
@chrisvest @normanmaurer
Make unpooled buffers avoid shared arenas (#16443)
c5db78c
Motivation:
Shared arenas can be expensive to close if we do it a lot, for instance
in cases when we use the UnpooledByteBufAllocator.

Modification:
Make Unpooled buffers avoid shared arenas and instead fall back to
GC/reference processing buffer cleaning. Make the pooling allocators
explicitly state that they permit "expensive" clean operations to that
they use shared arenas.

Result:
Greatly improves system-wide performance and scalability when allocating
a lot of unpooled buffers, at the cost of delayed cleaning/deallocation
and in turn higher memory usage.

This should also address a number of flaky test failures we see, that
are caused by timeouts due to increased time we were spending in closing
shared arenas.

If the use GC and reference counting causes adverse performance effects,
e.g. performance regressions or poor GC behavior, then the previous
behavior (letting unpooled buffers use shared memory segment arenas) can
be restored by setting the `io.netty.ignoreExpensiveClean=true` system
property.
@normanmaurer

normanmaurer commented Mar 14, 2026

Copy link
Copy Markdown
Member

Create PR manually due conflict... #16470

All reactions

Sorry, something went wrong.

Uh oh!

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

normanmaurer added a commit that referenced this pull request Mar 16, 2026
@normanmaurer @chrisvest
Make unpooled buffers avoid shared arenas (#16443) (#16470)
801efeb
Motivation:
Shared arenas can be expensive to close if we do it a lot, for instance
in cases when we use the UnpooledByteBufAllocator.

Modification:
Make Unpooled buffers avoid shared arenas and instead fall back to
GC/reference processing buffer cleaning. Make the pooling allocators
explicitly state that they permit "expensive" clean operations to that
they use shared arenas.

Result:
Greatly improves system-wide performance and scalability when allocating
a lot of unpooled buffers, at the cost of delayed cleaning/deallocation
and in turn higher memory usage.

This should also address a number of flaky test failures we see, that
are caused by timeouts due to increased time we were spending in closing
shared arenas.

If the use GC and reference counting causes adverse performance effects,
e.g. performance regressions or poor GC behavior, then the previous
behavior (letting unpooled buffers use shared memory segment arenas) can
be restored by setting the `io.netty.ignoreExpensiveClean=true` system
property.

---------

Co-authored-by: Chris Vest <[email protected]>
@chrisvest
chrisvest deleted the 4.2-unpooled-direct-buf branch March 16, 2026 22:51
@chrisvest chrisvest removed the needs-cherry-pick-5.0 This PR should be cherry-picked to 5.0 once merged. label Mar 17, 2026
@j-be j-be mentioned this pull request Apr 9, 2026
Potential memory leak after upgrading from 4.2.10 to 4.2.11 #16606
Closed
@franz1981 franz1981 mentioned this pull request May 7, 2026
Netty 4.2 and shared Arenas performance issues quarkusio/quarkus#54011
Closed
@normanmaurer normanmaurer mentioned this pull request Sep 22, 2026
suspend race fix #17588
Closed
@normanmaurer normanmaurer mentioned this pull request Oct 1, 2026
child5 #17695
Closed
This was referenced Oct 20, 2026
fix iouring zerocopy iov overwrite #17936
Closed
crisp nova cceda091 #18109
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@normanmaurer normanmaurer normanmaurer approved these changes
@franz1981 franz1981 franz1981 approved these changes

Uh oh!

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

Assignees

No one assigned

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.

5 participants

@chrisvest @yawkat @netty-project-bot @normanmaurer @franz1981
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.