Skip to content

Suspicious BUFFER_COUNT value in ConcurrentLruCache #36780

@kilink

Description

@kilink

The BUFFER_COUNT computed in ConcurrentLruCache.ReadOperations seems suspicious, since it's basically always just 4; it seems like the intention was to size things based on number of CPUs, but using Math.min here with 4 means that we always just end up with the value 4 (unless it's a uniprocessor machine). If it was intentional then the logic in detectNumberOfBuffers can be simplified, and there's no reason to try to find the next largest power of two. It feels like maybe the intent was to clamp the value to be a min of 4, but to allow a higher max size?

I have yet to benchmark it yet, but it should be easy enough to test out changing the logic to allow for actual buffer count values > 4.

See: https://github.com/spring-projects/spring-framework/blob/main/spring-core/src/main/java/org/springframework/util/ConcurrentLruCache.java#L453

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)status: waiting-for-feedbackWe need additional information before we can continuestatus: waiting-for-triageAn issue we've not yet triaged or decided on

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions