private Eviction constructEviction ( HeapCache hc , HeapCacheListener l , Cache2kConfiguration config ) { final boolean _strictEviction = config . isStrictEviction ( ) ; final int _availableProcessors = Runtime . getRuntime ( ) . availableProcessors ( ) ; final boolean _boostConcurrency = config . isBoostConcurrency ( ) ; final long _maximumWeight = config . getMaximumWeight ( ) ; long _entryCapacity = config . getEntryCapacity ( ) ; if ( _entryCapacity < 0 && _maximumWeight < 0 ) { _entryCapacity = 2000 ; } final int _segmentCountOverride = HeapCache . TUNABLE . segmentCountOverride ; int _segmentCount = determineSegmentCount ( _strictEviction , _availableProcessors , _boostConcurrency , _entryCapacity , _segmentCountOverride ) ; Eviction [ ] _segments = new Eviction [ _segmentCount ] ; long _maxSize = determineMaxSize ( _entryCapacity , _segmentCount ) ; long _maxWeight = determineMaxWeight ( _maximumWeight , _segmentCount ) ; final Weigher _weigher = ( Weigher ) hc . createCustomization ( config . getWeigher ( ) ) ; for ( int i = 0 ; i < _segments . length ; i ++ ) { Eviction ev = new ClockProPlusEviction ( hc , l , _maxSize , _weigher , _maxWeight ) ; _segments [ i ] = ev ; } if ( _segmentCount == 1 ) { return _segments [ 0 ] ; } return new SegmentedEviction ( _segments ) ; }
Construct segmented or queued eviction . For the moment hard coded . If capacity is at least 1000 we use 2 segments if 2 or more CPUs are available . Segmenting the eviction only improves for lots of concurrent inserts or evictions there is no effect on read performance .