Avoid BoxesRuntime indirection in LruBoundedCache key comparison (#31356)

By restricting the key type of `LruBoundedCache` to `AnyRef`, we can
avoid the indirection through `BoxesRuntime`, we remove some overhead
and potentially unlock some JVM optimizations here.
This commit is contained in:
Jason Zaugg 2022-04-22 16:32:15 +10:00 committed by GitHub
parent 146cc1af0f
commit 00c1da9944
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -23,7 +23,7 @@ private[akka] case class CacheStatistics(entries: Int, maxProbeDistance: Int, av
* to kick out entires that are considered old. The implementation tries to keep the map close to full, only evicting
* old entries when needed.
*/
private[akka] abstract class LruBoundedCache[K: ClassTag, V <: AnyRef: ClassTag](
private[akka] abstract class LruBoundedCache[K <: AnyRef: ClassTag, V <: AnyRef: ClassTag](
capacity: Int,
evictAgeThreshold: Int) {
require(capacity > 0, "Capacity must be larger than zero")