Skip to content

Conversation

@bandalgomsu
Copy link
Contributor

@bandalgomsu bandalgomsu commented Dec 4, 2025

This PR SharedLock.decrementWriters() to call threadWriters.remove() when the per-thread writer depth reaches zero, preventing unused ThreadLocal entries from lingering.
This helps avoid the ThreadLocalMap.expungeStaleEntry() CPU spikes reported in #3489

Thanks !

Make sure that:

  • You have read the contribution guidelines.
  • You have created a feature request first to discuss your contribution intent. Please reference the feature request ticket number in the pull request.
  • You applied code formatting rules using the mvn formatter:format target. Don’t submit any formatting related changes.
  • You submit test cases (unit or integration tests) that back your changes.

@a-TODO-rov
Copy link
Contributor

This might actually work. @tishun what do you think ?

Copy link
Contributor

@a-TODO-rov a-TODO-rov left a comment

Choose a reason for hiding this comment

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

Actually after second look and brief discussion with @tishun , there are some problems with that solution.
The main problem is same thread can go between 0 and 1 threadWriters very frequently in small interval of time, which creates a constant spike of ThreadLocal$SuppliedThreadLocal , which could lead to OOM error.

@bandalgomsu
Copy link
Contributor Author

Thanks for your feedback 🙂
I agree your comment

Then, what do you think about reducing the remove() frequency based on probability or an idle count threshold ??

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.

2 participants