[infinispan-dev] Faster LRU

Dan Berindei dan.berindei at gmail.com
Mon Jul 11 12:03:17 EDT 2011


On Fri, Jul 8, 2011 at 12:44 PM, Dan Berindei <dan.berindei at gmail.com> wrote:
>
> It's interesting that in the writeOnMiss test the new LRU performance
> dropped when I increased the concurrency level from 32 to 128. I think
> it might be because the eviction.thresholdExpired() check in
> BCHM.attemptEviction() is done without a lock and so it could return
> true simultaneously for multiple threads - which will all proceed to
> wait on the segment lock and attempt eviction at the same time.
>

I added another batch threshold check while holding the lock and the
performance anomaly disappeared.

> Another strange pattern is that neither eviction policy respects the
> capacity parameter exactly. LIRS rounds up the capacity to the next
> power of 2, and LRU/LRUOld do the same rounding and then multiply by
> 0.75.
>

I updated BCHM to pass the initial capacity to the eviction policy,
and now all the policies keep the same number of entries.

> I'll report again once I fixed these and once I update the reporting -
> I think the total number of misses might be more relevant than the
> standard deviation of the keys at the end.
>

I got the tests running on the test cluster again and the new LRU is
clearly better in every respect than the old LRU. In fact the only
"problem" in the test results is that in the new "writeOnMiss"
scenario the hit ratio of the new LRU is much better than all the
other policies. There is probably a mistake somewhere in the test, if
it was a random thing I don't think it would have been so visible in a
20-minutes test:

MapStressTest configuration: capacity 500000, test running time 1200 seconds
Container BCHM:LIRS     Ops/s   11155.49  HitRatio      96.54  Size
 499968  stdDev  193558.30
Container BCHM:LRU      Ops/s   31292.06  HitRatio      97.84  Size
 500000  stdDev  193168.07
Container BCHM:LRU_OLD  Ops/s     116.89  HitRatio      76.11  Size
 500032  stdDev  197974.87

Testing write on miss performance with capacity 500000, keys 2000000,
concurrency level 32, threads 100
Container BCHM:LIRS     Ops/s    1684.01  HitRatio      63.13  Size
 499968  stdDev  338637.40
Container BCHM:LRU      Ops/s    4884.57  HitRatio      84.47  Size
 500000  stdDev  353336.31
Container BCHM:LRU_OLD  Ops/s      50.69  HitRatio      41.34  Size
 500032  stdDev  361239.68
-------------- next part --------------
MapStressTest configuration: capacity 500000, test running time 1200 seconds
Testing independent read/write/remove performance with capacity 500000, keys 1000000, concurrency level 32, readers 90, writers 9, removers 1
Container BCHM:LIRS     Ops/s   14865.45  Gets/s   13971.36  Puts/s    8424.86  Removes/s    4640.39  HitRatio      83.10  Size     499972  StdDev  168386.87
Container BCHM:LRU      Ops/s   35970.38  Gets/s   33800.61  Puts/s   19273.89  Removes/s   21815.97  HitRatio      78.64  Size     500000  StdDev  192598.94
Container BCHM:LRU_OLD  Ops/s     496.10  Gets/s     467.32  Puts/s     258.91  Removes/s     269.63  HitRatio      69.66  Size     500032  StdDev  182468.36
Container CLHM          Ops/s   56074.13  Gets/s   50656.76  Puts/s   48274.11  Removes/s   53090.65  HitRatio      77.62  Size     500000  StdDev  180395.29
Container SLHM          Ops/s   20603.49  Gets/s   18110.83  Puts/s   22696.60  Removes/s   20080.24  HitRatio      80.12  Size     499401  StdDev  179188.12
[testng-MapStressTest] Test testReadWriteRemove(org.infinispan.stress.MapStressTest) succeeded.
Test suite progress: tests succeeded: 1, failed: 0, skipped: 0.
Testing independent read/write/remove performance with capacity 500000, keys 1000000, concurrency level 128, readers 90, writers 9, removers 1
Container BCHM:LIRS     Ops/s   23567.68  Gets/s   21558.38  Puts/s   19691.52  Removes/s    3617.48  HitRatio      84.73  Size     498450  StdDev  167244.66
Container BCHM:LRU      Ops/s   38313.89  Gets/s   35514.87  Puts/s   24921.89  Removes/s   27617.36  HitRatio      77.67  Size     500096  StdDev  193880.45
Container BCHM:LRU_OLD  Ops/s    2717.51  Gets/s    2600.66  Puts/s    1035.20  Removes/s    1197.20  HitRatio      79.14  Size     499573  StdDev  180107.36
Container CLHM          Ops/s   77609.22  Gets/s   70243.55  Puts/s   65605.74  Removes/s   72464.47  HitRatio      78.64  Size     499968  StdDev  182996.20
Container SLHM          Ops/s   18812.45  Gets/s   16125.15  Puts/s   25319.02  Removes/s   14003.08  HitRatio      81.44  Size     496624  StdDev  183041.62
[testng-MapStressTest] Test testReadWriteRemove(org.infinispan.stress.MapStressTest) succeeded.
Test suite progress: tests succeeded: 2, failed: 0, skipped: 0.
Testing independent read/write/remove performance with capacity 500000, keys 2000000, concurrency level 32, readers 90, writers 9, removers 1
Container BCHM:LIRS     Ops/s   10579.80  Gets/s   10346.59  Puts/s    2109.26  Removes/s    2002.00  HitRatio      50.88  Size     499969  StdDev  245820.97
Container BCHM:LRU      Ops/s   35180.30  Gets/s   34372.36  Puts/s    6871.62  Removes/s   10867.85  HitRatio      50.08  Size     500000  StdDev  261253.40
Container BCHM:LRU_OLD  Ops/s     581.95  Gets/s     567.70  Puts/s     120.29  Removes/s     186.90  HitRatio      41.77  Size     498488  StdDev  272488.66
Container CLHM          Ops/s   69350.05  Gets/s   63394.81  Puts/s   52409.63  Removes/s   64287.81  HitRatio      48.10  Size     500000  StdDev  293709.24
Container SLHM          Ops/s   22891.65  Gets/s   19814.09  Puts/s   28554.99  Removes/s   19997.05  HitRatio      46.53  Size     500000  StdDev  311021.06
[testng-MapStressTest] Test testReadWriteRemove(org.infinispan.stress.MapStressTest) succeeded.
Test suite progress: tests succeeded: 3, failed: 0, skipped: 0.
Testing independent read/write/remove performance with capacity 500000, keys 2000000, concurrency level 128, readers 90, writers 9, removers 1
Container BCHM:LIRS     Ops/s   13702.34  Gets/s   13412.82  Puts/s    2635.95  Removes/s    2315.04  HitRatio      51.69  Size     499826  StdDev  246800.07
Container BCHM:LRU      Ops/s   38653.08  Gets/s   37709.32  Puts/s    7254.65  Removes/s   19645.49  HitRatio      49.17  Size     500096  StdDev  269490.28
Container BCHM:LRU_OLD  Ops/s    3750.79  Gets/s    3696.71  Puts/s     406.55  Removes/s    1198.34  HitRatio      48.59  Size     500224  StdDev  265584.03
Container CLHM          Ops/s   86802.22  Gets/s   79402.95  Puts/s   65007.29  Removes/s   80882.28  HitRatio      47.82  Size     499968  StdDev  293656.32
Container SLHM          Ops/s   22484.50  Gets/s   19452.19  Puts/s   28160.86  Removes/s   19465.18  HitRatio      46.74  Size     500000  StdDev  303430.85
[testng-MapStressTest] Test testReadWriteRemove(org.infinispan.stress.MapStressTest) succeeded.


MapStressTest configuration: capacity 500000, test running time 1200 seconds
Testing mixed read/write performance with capacity 500000, keys 1000000, concurrency level 32, threads 100, read:write ratio 9:1
Container BCHM:LIRS     Ops/s   13622.31  Gets/s   12260.08  Puts/s    1362.23  HitRatio      85.18  Size     499968  stdDev  164014.63
Container BCHM:LRU      Ops/s   30877.97  Gets/s   27790.18  Puts/s    3087.80  HitRatio      84.12  Size     500000  stdDev  168540.19
Container BCHM:LRU_OLD  Ops/s     327.80  Gets/s     295.02  Puts/s      32.78  HitRatio      78.21  Size     500024  stdDev  170959.46
Container CLHM          Ops/s   46446.66  Gets/s   41801.99  Puts/s    4644.67  HitRatio      84.09  Size     500000  stdDev  170714.58
Container SLHM          Ops/s   17666.48  Gets/s   15899.83  Puts/s    1766.65  HitRatio      84.29  Size     500000  stdDev  171891.36
[testng-MapStressTest] Test testMixedReadWrite(org.infinispan.stress.MapStressTest) succeeded.
Test suite progress: tests succeeded: 1, failed: 0, skipped: 0.
Testing mixed read/write performance with capacity 500000, keys 1000000, concurrency level 128, threads 100, read:write ratio 9:1
Container BCHM:LIRS     Ops/s   20786.78  Gets/s   18708.11  Puts/s    2078.68  HitRatio      85.42  Size     499968  stdDev  168066.84
Container BCHM:LRU      Ops/s   31592.99  Gets/s   28433.69  Puts/s    3159.30  HitRatio      84.60  Size     500096  stdDev  169102.54
Container BCHM:LRU_OLD  Ops/s    2629.30  Gets/s    2366.37  Puts/s     262.93  HitRatio      83.90  Size     500187  stdDev  170475.93
Container CLHM          Ops/s   65238.82  Gets/s   58714.93  Puts/s    6523.88  HitRatio      84.06  Size     499968  stdDev  171157.73
Container SLHM          Ops/s   17521.77  Gets/s   15769.59  Puts/s    1752.18  HitRatio      84.17  Size     500000  stdDev  170159.28
[testng-MapStressTest] Test testMixedReadWrite(org.infinispan.stress.MapStressTest) succeeded.
Test suite progress: tests succeeded: 2, failed: 0, skipped: 0.
Testing mixed read/write performance with capacity 500000, keys 2000000, concurrency level 32, threads 100, read:write ratio 9:1
Container BCHM:LIRS     Ops/s    5647.27  Gets/s    5082.54  Puts/s     564.73  HitRatio      50.50  Size     499968  stdDev  257501.09
Container BCHM:LRU      Ops/s   14951.19  Gets/s   13456.07  Puts/s    1495.12  HitRatio      48.23  Size     500000  stdDev  295293.75
Container BCHM:LRU_OLD  Ops/s     280.30  Gets/s     252.27  Puts/s      28.03  HitRatio      45.21  Size     500032  stdDev  301494.74
Container CLHM          Ops/s   58257.25  Gets/s   52431.52  Puts/s    5825.72  HitRatio      47.43  Size     500000  stdDev  292936.48
Container SLHM          Ops/s   20742.20  Gets/s   18667.98  Puts/s    2074.22  HitRatio      48.07  Size     500000  stdDev  297571.08
[testng-MapStressTest] Test testMixedReadWrite(org.infinispan.stress.MapStressTest) succeeded.
Test suite progress: tests succeeded: 3, failed: 0, skipped: 0.
Testing mixed read/write performance with capacity 500000, keys 2000000, concurrency level 128, threads 100, read:write ratio 9:1
Container BCHM:LIRS     Ops/s    8797.80  Gets/s    7918.02  Puts/s     879.78  HitRatio      50.80  Size     499968  stdDev  267553.95
Container BCHM:LRU      Ops/s   15410.37  Gets/s   13869.33  Puts/s    1541.04  HitRatio      47.52  Size     500096  stdDev  294696.35
Container BCHM:LRU_OLD  Ops/s    2037.67  Gets/s    1833.91  Puts/s     203.77  HitRatio      46.98  Size     500224  stdDev  302162.31
Container CLHM          Ops/s   70272.09  Gets/s   63244.88  Puts/s    7027.21  HitRatio      47.71  Size     499968  stdDev  295697.77
Container SLHM          Ops/s   20714.08  Gets/s   18642.67  Puts/s    2071.41  HitRatio      47.74  Size     500000  stdDev  296287.32
[testng-MapStressTest] Test testMixedReadWrite(org.infinispan.stress.MapStressTest) succeeded.


MapStressTest configuration: capacity 500000, test running time 1200 seconds
Testing write on miss performance with capacity 500000, keys 1000000, concurrency level 32, threads 100
Container BCHM:LIRS     Ops/s   11155.49  HitRatio      96.54  Size     499968  stdDev  193558.30
Container BCHM:LRU      Ops/s   31292.06  HitRatio      97.84  Size     500000  stdDev  193168.07
Container BCHM:LRU_OLD  Ops/s     116.89  HitRatio      76.11  Size     500032  stdDev  197974.87
Container CLHM          Ops/s   34691.21  HitRatio      80.70  Size     500000  stdDev  192696.86
Container SLHM          Ops/s   13494.16  HitRatio      79.11  Size     500000  stdDev  192849.83
[testng-MapStressTest] Test testWriteOnMiss(org.infinispan.stress.MapStressTest) succeeded.
Test suite progress: tests succeeded: 1, failed: 0, skipped: 0.
Testing write on miss performance with capacity 500000, keys 1000000, concurrency level 128, threads 100
Container BCHM:LIRS     Ops/s   18987.69  HitRatio      96.57  Size     499968  stdDev  193454.62
Container BCHM:LRU      Ops/s   30248.14  HitRatio      97.85  Size     500096  stdDev  193437.99
Container BCHM:LRU_OLD  Ops/s     938.86  HitRatio      82.39  Size     500224  stdDev  194889.45
Container CLHM          Ops/s   44122.21  HitRatio      78.52  Size     499968  stdDev  192738.30
Container SLHM          Ops/s   14022.65  HitRatio      79.27  Size     500000  stdDev  192918.10
[testng-MapStressTest] Test testWriteOnMiss(org.infinispan.stress.MapStressTest) succeeded.
Test suite progress: tests succeeded: 2, failed: 0, skipped: 0.
Testing write on miss performance with capacity 500000, keys 2000000, concurrency level 32, threads 100
Container BCHM:LIRS     Ops/s    1684.01  HitRatio      63.13  Size     499968  stdDev  338637.40
Container BCHM:LRU      Ops/s    4884.57  HitRatio      84.47  Size     500000  stdDev  353336.31
Container BCHM:LRU_OLD  Ops/s      50.69  HitRatio      41.34  Size     500032  stdDev  361239.68
Container CLHM          Ops/s   17734.21  HitRatio      45.10  Size     500000  stdDev  349757.79
Container SLHM          Ops/s    9161.64  HitRatio      44.16  Size     500000  stdDev  349731.13
[testng-MapStressTest] Test testWriteOnMiss(org.infinispan.stress.MapStressTest) succeeded.
Test suite progress: tests succeeded: 3, failed: 0, skipped: 0.
Testing write on miss performance with capacity 500000, keys 2000000, concurrency level 128, threads 100
Container BCHM:LIRS     Ops/s    3032.77  HitRatio      78.47  Size     499968  stdDev  348946.80
Container BCHM:LRU      Ops/s    4903.54  HitRatio      85.05  Size     500096  stdDev  352937.00
Container BCHM:LRU_OLD  Ops/s     256.37  HitRatio      42.63  Size     500224  stdDev  354679.78
Container CLHM          Ops/s   18170.50  HitRatio      43.28  Size     499968  stdDev  349153.97
Container SLHM          Ops/s    9234.12  HitRatio      44.10  Size     500000  stdDev  350081.16
[testng-MapStressTest] Test testWriteOnMiss(org.infinispan.stress.MapStressTest) succeeded.



More information about the infinispan-dev mailing list