Skip to content

Recycler should not use thread locals unless they get cleaned up#16315

Merged
normanmaurer merged 3 commits into
netty:4.2from
chrisvest:4.2-ftl-recycler
Feb 23, 2026
Merged

Recycler should not use thread locals unless they get cleaned up#16315
normanmaurer merged 3 commits into
netty:4.2from
chrisvest:4.2-ftl-recycler

Conversation

@chrisvest
Copy link
Copy Markdown
Member

Motivation:
The Recycler is used for a lot of resources, such as ByteBuf and PoolThreadCache, that rely on GC effects or reference processing. These effects can be greatly delayed if thread local references aren't cleared when threads terminate.

Modification:
Instead of checking whether FastThreadLocals are supported by the current thread, the Recycler now instead checks if thread locals are cleaned. The cleaning of thread locals is the effect we really care about.

Result:
Code, test and production alike, that rely on the timeliness of these effects become more deterministic.

Motivation:
The Recycler is used for a lot of resources, such as ByteBuf and PoolThreadCache, that rely on GC effects or reference processing.
These effects can be greatly delayed if thread local references aren't cleared when threads terminate.

Modification:
Instead of checking whether FastThreadLocals are _supported_ by the current thread, the Recycler now instead checks if thread locals are _cleaned_.
The cleaning of thread locals is the effect we really care about.

Result:
Code, test and production alike, that rely on the timeliness of these effects become more deterministic.
@chrisvest chrisvest added this to the 4.2.11.Final milestone Feb 20, 2026
@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. labels Feb 20, 2026
@chrisvest
Copy link
Copy Markdown
Member Author

This PR needs #16314 to be merged first, before the Recycler test suite will pass.

@normanmaurer normanmaurer merged commit 77e2a68 into netty:4.2 Feb 23, 2026
19 checks passed
netty-project-bot pushed a commit that referenced this pull request Feb 23, 2026
)

Motivation:
The Recycler is used for a lot of resources, such as ByteBuf and
PoolThreadCache, that rely on GC effects or reference processing. These
effects can be greatly delayed if thread local references aren't cleared
when threads terminate.

Modification:
Instead of checking whether FastThreadLocals are _supported_ by the
current thread, the Recycler now instead checks if thread locals are
_cleaned_. The cleaning of thread locals is the effect we really care
about.

Result:
Code, test and production alike, that rely on the timeliness of these
effects become more deterministic.

Co-authored-by: Norman Maurer <norman_maurer@apple.com>
(cherry picked from commit 77e2a68)
@netty-project-bot
Copy link
Copy Markdown
Contributor

Auto-port PR for 5.0: #16335

@netty-project-bot
Copy link
Copy Markdown
Contributor

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

@github-actions github-actions Bot removed the needs-cherry-pick-5.0 This PR should be cherry-picked to 5.0 once merged. label Feb 23, 2026
chrisvest added a commit that referenced this pull request Feb 23, 2026
…cleaned up (#16335)

Auto-port of #16315 to 5.0
Cherry-picked commit: 77e2a68

---
Motivation:
The Recycler is used for a lot of resources, such as ByteBuf and
PoolThreadCache, that rely on GC effects or reference processing. These
effects can be greatly delayed if thread local references aren't cleared
when threads terminate.

Modification:
Instead of checking whether FastThreadLocals are _supported_ by the
current thread, the Recycler now instead checks if thread locals are
_cleaned_. The cleaning of thread locals is the effect we really care
about.

Result:
Code, test and production alike, that rely on the timeliness of these
effects become more deterministic.

Co-authored-by: Chris Vest <christianvest_hansen@apple.com>
Co-authored-by: Norman Maurer <norman_maurer@apple.com>
@chrisvest chrisvest removed the needs-cherry-pick-4.1 This PR should be cherry-picked to 4.1 once merged. label Feb 23, 2026
@chrisvest
Copy link
Copy Markdown
Member Author

Quite a lot of changes to the Recycler between 4.1 and 4.2, so I don't think it make sense to backport.

@chrisvest chrisvest deleted the 4.2-ftl-recycler branch February 23, 2026 18:33
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