Simplify BUFFER_COUNT in ConcurrentLruCache to a constant#36872
Merged
bclozel merged 1 commit intoJun 4, 2026
Merged
Conversation
Member
|
@s-chan-o please sign off your commit, we cannot accept this contribution without it. Thanks |
32f294a to
592ab02
Compare
Contributor
Author
The detectNumberOfBuffers() method attempted to scale the read buffer count based on the number of available processors, but used Math.min(4, nextPowerOfTwo) which effectively caps the result at 4 regardless of CPU count. For systems with fewer than 3 processors, the buffer count would be reduced below 4, but this edge case adds complexity without measurable benefit. Simplify BUFFER_COUNT to a constant value of 4, removing the unnecessary CPU-detection logic. Closes spring-projectsgh-36872 Signed-off-by: seungchan <s24041@gsm.hs.kr>
592ab02 to
4c6194a
Compare
Member
|
Thanks for your contribution @s-chan-o ! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
The
detectNumberOfBuffers()method inConcurrentLruCache.ReadOperationsattempts to scale the read buffer count based on the number of available processors:However, the use of
Math.min(4, nextPowerOfTwo)caps the result at 4 for any system with 3 or more processors. For systems with 5+ processors,nextPowerOfTwowould be 8 or more, but theMath.minalways returns 4. The CPU-detection logic adds complexity without any actual effect for the vast majority of deployment environments.As noted in gh-36780, the value is "basically always just 4".
Fix
Simplify
BUFFER_COUNTto a plain constant4, removing thedetectNumberOfBuffers()method entirely. This is consistent with the feedback from gh-29520 that informed the original cap at 4.Closes gh-36780