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 — Always prefer direct buffers for pooled allocators if not explicit di… by normanmaurer · Pull Request #15232 · netty/netty

Conversation

@normanmaurer

@normanmaurer normanmaurer commented May 22, 2025

Copy link
Copy Markdown
Member

…sabled

Motivation:

We should always prefer direct buffers if the ByteBufAllocator implementations are pooled as deallocating these buffers should be rare.

Modifications:

  • Add new method to PlatformDependent that can be used to check if default direct buffer usage was explicit disabled
  • Use this method in our pooled ByteBufAllocator implementations to check if we should use direct buffers or not by default

Result:

Less memory copies and better performance when using the pooled allocators even if Unsafe can not be used.

Sorry, something went wrong.

Uh oh!

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

doom369 reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@normanmaurer
normanmaurer requested review from chrisvest and franz1981 May 22, 2025 06:53
@normanmaurer normanmaurer added this to the 4.2.2.Final milestone May 22, 2025
@normanmaurer normanmaurer mentioned this pull request May 22, 2025
Add support for creating direct ByteBuffers from MemorySegments #15231
Merged
franz1981
franz1981 reviewed May 22, 2025
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.

We could even wait till @chrisvest changes are merged and consider safe to always use direct ones only if the cleaner won't delay freeing up them e.g. Unsafe and FFM versions.
This will make a more elastic and effective ergonomics

Sorry, something went wrong.

Uh oh!

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

All reactions
@normanmaurer

normanmaurer commented May 22, 2025

Copy link
Copy Markdown
Member Author

@franz1981 maybe... I think this change might still be a good one even without what @chrisvest did. Especially when thinking about 4.1

All reactions

Sorry, something went wrong.

Uh oh!

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

chrisvest
chrisvest approved these changes May 22, 2025
View reviewed changes
@normanmaurer
Always prefer direct buffers for pooled allocators if not explicit di…
25ca875
…sabled

Motivation:

We should always prefer direct buffers if the ByteBufAllocator implementations are pooled as deallocating these buffers should be rare.

Modifications:

- Add new method to PlatformDependent that can be used to check if default direct buffer usage was explicit disabled
- Use this method in our pooled ByteBufAllocator implementations to check if we should use direct buffers or not by default

Result:

Less memory copies and better performance when using the pooled allocators even if Unsafe can not be used.
@normanmaurer
normanmaurer force-pushed the prefer_direct_buffers_pooled branch from 7c28748 to 25ca875 Compare May 22, 2025 16:31
@normanmaurer
normanmaurer merged commit 7e96030 into 4.2 May 22, 2025
@normanmaurer
normanmaurer deleted the prefer_direct_buffers_pooled branch May 22, 2025 16:31
@normanmaurer

normanmaurer commented May 22, 2025

Copy link
Copy Markdown
Member Author

@chrisvest I think we also want this for 4.1, agree ?

All reactions

Sorry, something went wrong.

Uh oh!

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

@chrisvest

chrisvest commented May 22, 2025

Copy link
Copy Markdown
Member

@chrisvest I think we also want this for 4.1, agree ?

Sure

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

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 May 22, 2025
@normanmaurer
Always prefer direct buffers for pooled allocators if not explicit di… (
ba1b653
#15232)

…sabled

Motivation:

We should always prefer direct buffers if the ByteBufAllocator
implementations are pooled as deallocating these buffers should be rare.

Modifications:

- Add new method to PlatformDependent that can be used to check if
default direct buffer usage was explicit disabled
- Use this method in our pooled ByteBufAllocator implementations to
check if we should use direct buffers or not by default

Result:

Less memory copies and better performance when using the pooled
allocators even if Unsafe can not be used.
@normanmaurer normanmaurer mentioned this pull request May 22, 2025
Always prefer direct buffers for pooled allocators if not explicit di… #15245
Merged
normanmaurer added a commit that referenced this pull request May 23, 2025
@normanmaurer
Always prefer direct buffers for pooled allocators if not explicit di… (
6ea4c6c
#15245)

…… (#15232)

…sabled

Motivation:

We should always prefer direct buffers if the ByteBufAllocator
implementations are pooled as deallocating these buffers should be rare.

Modifications:

- Add new method to PlatformDependent that can be used to check if
default direct buffer usage was explicit disabled
- Use this method in our pooled ByteBufAllocator implementations to
check if we should use direct buffers or not by default

Result:

Less memory copies and better performance when using the pooled
allocators even if Unsafe can not be used.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@franz1981 franz1981 franz1981 left review comments
@chrisvest chrisvest chrisvest 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.2.Final

Development

Successfully merging this pull request may close these issues.

Uh oh!

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

3 participants

@normanmaurer @chrisvest @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.