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 — allow LocalChannel queue to be overridden by descendants and use a default Queue that allocates less by JerryShea · Pull Request #15993 · netty/netty

Conversation

@JerryShea

@JerryShea JerryShea commented Dec 9, 2025 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown

Motivation:

To reduce the allocations generated by LocalChannel's Queue.

Modifications:

Modify code to allow users to provide their own Queue impl. Use a default Queue impl that allocates less.

Result:

Less GC. Fixes some parts of #15994

Sorry, something went wrong.

Uh oh!

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

All reactions
@JerryShea JerryShea mentioned this pull request Dec 9, 2025
less garbage/more extensibility of LocalChannel #15994
Open
@JerryShea JerryShea changed the title allow LocalChannel queue to be overridden by descendants and … allow LocalChannel queue to be overridden by descendants and remove allocations for finishPeerReadTask Dec 9, 2025
normanmaurer
normanmaurer reviewed Dec 9, 2025
View reviewed changes
Comment thread transport/src/main/java/io/netty/channel/local/LocalChannel.java
return state == State.CONNECTED;
}

protected Queue<Object> newQueue() {

@normanmaurer normanmaurer Dec 9, 2025

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.

@JerryShea what kind of implementation you look to use here ? I wonder if we can't just use something better by default ?

Sorry, something went wrong.

Uh oh!

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

All reactions

@JerryShea JerryShea Dec 9, 2025

Copy link
Copy Markdown
Author

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.

Hi @normanmaurer - we are currently trying out a few different implementations, including MpscChunkedArrayQueue (which allocates a lot less, and is already used by Recycler). My thinking was to make LocalChannel behave similarly to DefaultEventLoop#newTaskQueue - IMO it would be ideal if we could make it pluggable to allow maximal flexibility.
Our testing is ongoing (with a few different Queue impls), so I can't yet confirm if MpscChunkedArrayQueue is definitely a better solution but I'll certainly keep you posted.

Sorry, something went wrong.

Uh oh!

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

All reactions

@chrisvest chrisvest Dec 10, 2025

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.

JCTools also has SPSC versions of the chunked array queue. We could add a PlatformDependent.newFixedSpscQueue(int) method for that purpose.

Sorry, something went wrong.

Uh oh!

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

All reactions

@JerryShea JerryShea Dec 10, 2025

Copy link
Copy Markdown
Author

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.

Thanks @chrisvest - I agree that SpscChunkedArrayQueue would make a very sensible default.

Sorry, something went wrong.

Uh oh!

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

All reactions
@normanmaurer

normanmaurer commented Dec 9, 2025

Copy link
Copy Markdown
Member

@JerryShea seems like your change introduced test-failures... PTAL

2025-12-09T17:35:09.3474480Z [ERROR]   LocalChannelTest.testCloseInWritePromiseCompletePreservesOrder:386 expected: <true> but was: <false>
All reactions

Sorry, something went wrong.

Uh oh!

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

@JerryShea

JerryShea commented Dec 10, 2025

Copy link
Copy Markdown
Author

@JerryShea seems like your change introduced test-failures... PTAL

2025-12-09T17:35:09.3474480Z [ERROR]   LocalChannelTest.testCloseInWritePromiseCompletePreservesOrder:386 expected: <true> but was: <false>

Woops, let me look into - thanks @normanmaurer

All reactions

Sorry, something went wrong.

Uh oh!

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

@normanmaurer

normanmaurer commented Dec 10, 2025

Copy link
Copy Markdown
Member

@JerryShea let me know once I should review again

All reactions

Sorry, something went wrong.

Uh oh!

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

JerryShea
JerryShea commented Dec 11, 2025
View reviewed changes
Comment thread common/src/main/java/io/netty/util/internal/PlatformDependent.java Outdated
* Create a new {@link Queue} which is safe to use for single producer (one thread!) and a single
* consumer (one thread!).
*/
public static <T> Queue<T> newChunkedSpscQueue(final int chunkSize, final int capacity) {

@JerryShea JerryShea Dec 11, 2025

Copy link
Copy Markdown
Author

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.

@chrisvest I called it "...Chunked..." in the end to make consistent with newChunkedMpscQueue

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
@JerryShea
JerryShea force-pushed the feature/local-channel-perf branch 2 times, most recently from 4d4b2fb to 68a9b27 Compare December 11, 2025 04:21
JerryShea
JerryShea commented Dec 11, 2025
View reviewed changes
Comment thread transport/src/main/java/io/netty/channel/local/LocalChannel.java Outdated
}

protected <T> Queue<T> newQueue() {
return PlatformDependent.newChunkedSpscQueue(1024, 4 << 20);

@JerryShea JerryShea Dec 11, 2025

Copy link
Copy Markdown
Author

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.

seeking the advice of netty maintainers here regarding how best to configure this

Sorry, something went wrong.

Uh oh!

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

All reactions

@JerryShea JerryShea Dec 12, 2025

Copy link
Copy Markdown
Author

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've used system properties like the Recycle. @chrisvest @normanmaurer hope this all looks OK now - I think it is ready for review again

Sorry, something went wrong.

Uh oh!

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

All reactions
@JerryShea

JerryShea commented Dec 11, 2025

Copy link
Copy Markdown
Author

@JerryShea let me know once I should review again

All the tests now pass. Please re-review @normanmaurer

It is by no means finished but seems to work well. It imrpoves garbage and performance for our workload.

All reactions

Sorry, something went wrong.

Uh oh!

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

@normanmaurer

normanmaurer commented Dec 11, 2025

Copy link
Copy Markdown
Member

@JerryShea I think this is a better fix for the Runnable reuse without need an extra queue: #16014

All reactions

Sorry, something went wrong.

Uh oh!

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

@JerryShea

JerryShea commented Dec 11, 2025 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Author

@JerryShea I think this is a better fix for the Runnable reuse without need an extra queue: #16014

oh that is much nicer. I will remove those changes from my branch and rebase mine on yours (or cherry-pick) and test locally

All reactions

Sorry, something went wrong.

Uh oh!

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

@JerryShea

JerryShea commented Dec 11, 2025

Copy link
Copy Markdown
Author

I see your PR is against 4.2. Would you prefer we make these changes against 4.2 in the first instance and then backport to 4.1? We are still running 4.1 still...

All reactions

Sorry, something went wrong.

Uh oh!

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

@normanmaurer

normanmaurer commented Dec 11, 2025

Copy link
Copy Markdown
Member

@JerryShea usually we do 4.2 first and then back port

All reactions

Sorry, something went wrong.

Uh oh!

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

@JerryShea
JerryShea force-pushed the feature/local-channel-perf branch 2 times, most recently from 24c8ec7 to ab8c37f Compare December 11, 2025 05:38
@JerryShea

JerryShea commented Dec 11, 2025

Copy link
Copy Markdown
Author

@JerryShea usually we do 4.2 first and then back port

OK, tomorrow I will re-apply to 4.2, which means I can then cherry pick your commit instead of manually copying

All reactions

Sorry, something went wrong.

Uh oh!

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

@JerryShea
JerryShea force-pushed the feature/local-channel-perf branch 2 times, most recently from a265a76 to 9a6c14f Compare December 11, 2025 22:25
@JerryShea
JerryShea changed the base branch from 4.1 to local_less_gc December 11, 2025 22:26
@JerryShea
JerryShea changed the base branch from local_less_gc to 4.2 December 11, 2025 22:27
@JerryShea
JerryShea force-pushed the feature/local-channel-perf branch 2 times, most recently from 5010c40 to 42001ec Compare December 12, 2025 00:17
@JerryShea

JerryShea commented Dec 13, 2025

Copy link
Copy Markdown
Author

@JerryShea usually we do 4.2 first and then back port

OK, tomorrow I will re-apply to 4.2, which means I can then cherry pick your commit instead of manually copying

@normanmaurer I believe this is ready for the next review

All reactions

Sorry, something went wrong.

Uh oh!

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

normanmaurer
normanmaurer approved these changes Dec 13, 2025
View reviewed changes
@JerryShea JerryShea changed the title allow LocalChannel queue to be overridden by descendants and remove allocations for finishPeerReadTask allow LocalChannel queue to be overridden by descendants and use a default Queue that allocates less Dec 13, 2025
@JerryShea

JerryShea commented Dec 13, 2025

Copy link
Copy Markdown
Author

Thanks for the tick @normanmaurer - please see also #16035

All reactions

Sorry, something went wrong.

Uh oh!

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

@normanmaurer
normanmaurer requested a review from chrisvest December 14, 2025 10:18
@JerryShea
JerryShea force-pushed the feature/local-channel-perf branch from 42001ec to c6b9123 Compare December 14, 2025 23:07
@JerryShea
JerryShea force-pushed the feature/local-channel-perf branch from 3a05430 to 3e5f138 Compare December 17, 2025 02:15
@JerryShea
JerryShea force-pushed the feature/local-channel-perf branch from 3e5f138 to 3b0959f Compare April 6, 2026 21:50
@JerryShea JerryShea mentioned this pull request Apr 7, 2026
allow LocalChannel queue to be overridden by descendants - use SpscChunked*ArrayQueue as the default #16035
Open
@JerryShea

JerryShea commented Apr 7, 2026

Copy link
Copy Markdown
Author

I've rebased and pushed. This PR contains the same changes as the 4.1 PR. Sorry I should have just created one PR! I can delete one if the maintainers prefer.

All reactions

Sorry, something went wrong.

Uh oh!

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

@JerryShea
JerryShea force-pushed the feature/local-channel-perf branch from 3b0959f to 6a98de4 Compare April 7, 2026 20:14
JerryShea and others added 3 commits April 10, 2026 08:49
@JerryShea
allow LocalChannel queue to be overridden by descendants - use SpscCh…
3ad916a
…unked*ArrayQueue as the default
@JerryShea
code review comment - unbounded queue
963da02
@JerryShea
remove usage of SpscLinkedQueue/SpscLinkedAtomicQueue as per @franz1981…
28cffbc
… suggestion
@JerryShea
JerryShea force-pushed the feature/local-channel-perf branch from 6a98de4 to 28cffbc Compare April 9, 2026 22:49
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
@chrisvest chrisvest Awaiting requested review from chrisvest

Uh oh!

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

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

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

3 participants

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