Skip to content

Latest commit

 

History

History
293 lines (244 loc) · 14.7 KB

README.md

File metadata and controls

293 lines (244 loc) · 14.7 KB

Cache benchmark for Go

This benchmark compares cache eviction algorithms using Zipfian distribution.

This referred to this code a lot.

This evaluation results wes proceeded on my desktop. It will show different results depending on execution environments.

Cache libraries used

Name Ref
sieve https://github.com/scalalang2/golang-fifo
s3-fifo https://github.com/scalalang2/golang-fifo
s3-fifo (otter) https://github.com/maypok86/otter
clock https://github.com/Code-Hex/go-generics-cache
lru-hashicorp https://github.com/hashicorp/golang-lru
lru-groupcache https://github.com/golang/groupcache/lru
two-queue https://github.com/hashicorp/golang-lru
s4-lru https://github.com/dgryski/go-s4lru
tinylfu https://github.com/dgryski/go-tinylfu
$ go run *.go

itemSize=500000, workloads=7500000, cacheSize=0.10%, zipf's alpha=0.99, concurrency=1

       CACHE      | HITRATE |   QPS    |  HITS   | MISSES
------------------+---------+----------+---------+----------
  otter           | 47.43%  |  3311258 | 3557498 | 3942502
  sieve           | 47.42%  |  5053908 | 3556217 | 3943783
  tinylfu         | 47.37%  |  5559674 | 3552888 | 3947112
  s3-fifo         | 47.16%  |  2650177 | 3537110 | 3962890
  slru            | 46.48%  |  3945292 | 3486209 | 4013791
  s4lru           | 46.15%  |  7716049 | 3461183 | 4038817
  two-queue       | 45.49%  |  2846300 | 3411961 | 4088039
  clock           | 37.34%  |  5292872 | 2800767 | 4699233
  freelru-sharded | 36.63%  | 12711864 | 2747389 | 4752611
  lru-hashicorp   | 36.59%  |  4649721 | 2744181 | 4755819
  lru-groupcache  | 36.59%  |  4422170 | 2744181 | 4755819
  freelru-synced  | 36.59%  | 12668919 | 2744181 | 4755819


itemSize=500000, workloads=7500000, cacheSize=0.10%, zipf's alpha=0.99, concurrency=2

       CACHE      | HITRATE |   QPS   |  HITS   | MISSES
------------------+---------+---------+---------+----------
  sieve           | 47.58%  | 3104305 | 3568241 | 3931759
  otter           | 47.48%  | 4485646 | 3561202 | 3938798
  tinylfu         | 47.37%  | 3683694 | 3552877 | 3947123
  s3-fifo         | 47.17%  | 2020474 | 3537617 | 3962383
  slru            | 46.48%  | 3220266 | 3486274 | 4013726
  s4lru           | 46.15%  | 4854369 | 3461428 | 4038572
  two-queue       | 45.50%  | 2265177 | 3412695 | 4087305
  clock           | 37.33%  | 3768844 | 2799597 | 4700403
  freelru-sharded | 36.62%  | 8278146 | 2746505 | 4753495
  lru-groupcache  | 36.58%  | 3464203 | 2743803 | 4756197
  lru-hashicorp   | 36.58%  | 3561254 | 2743775 | 4756225
  freelru-synced  | 36.58%  | 7995736 | 2743493 | 4756507


itemSize=500000, workloads=7500000, cacheSize=0.10%, zipf's alpha=0.99, concurrency=4

       CACHE      | HITRATE |   QPS   |  HITS   | MISSES
------------------+---------+---------+---------+----------
  otter           | 47.80%  | 5510654 | 3584825 | 3915175
  sieve           | 47.77%  | 2762431 | 3582402 | 3917598
  tinylfu         | 47.37%  | 3280840 | 3553026 | 3946974
  s3-fifo         | 47.16%  | 1958225 | 3537165 | 3962835
  slru            | 46.49%  | 3009631 | 3486597 | 4013403
  s4lru           | 46.16%  | 4315305 | 3461643 | 4038357
  two-queue       | 45.49%  | 2085651 | 3411995 | 4088005
  clock           | 37.33%  | 3566334 | 2799694 | 4700306
  freelru-sharded | 36.62%  | 7591093 | 2746349 | 4753651
  lru-groupcache  | 36.58%  | 3171247 | 2743415 | 4756585
  freelru-synced  | 36.57%  | 6421233 | 2743084 | 4756916
  lru-hashicorp   | 36.56%  | 3211991 | 2742353 | 4757647


itemSize=500000, workloads=7500000, cacheSize=0.10%, zipf's alpha=0.99, concurrency=8

       CACHE      | HITRATE |   QPS   |  HITS   | MISSES
------------------+---------+---------+---------+----------
  otter           | 50.36%  | 6082725 | 3776656 | 3723344
  sieve           | 47.65%  | 2521008 | 3573569 | 3926431
  tinylfu         | 47.37%  | 3312721 | 3552852 | 3947148
  s3-fifo         | 47.15%  | 1934985 | 3536597 | 3963403
  slru            | 46.48%  | 2927400 | 3486227 | 4013773
  s4lru           | 46.14%  | 3978780 | 3460543 | 4039457
  two-queue       | 45.49%  | 2064410 | 3412067 | 4087933
  clock           | 37.33%  | 3412193 | 2799919 | 4700081
  freelru-sharded | 36.62%  | 8073197 | 2746186 | 4753814
  freelru-synced  | 36.57%  | 5933544 | 2743019 | 4756981
  lru-groupcache  | 36.57%  | 3156566 | 2742945 | 4757055
  lru-hashicorp   | 36.56%  | 3027856 | 2742193 | 4757807


itemSize=500000, workloads=7500000, cacheSize=0.10%, zipf's alpha=0.99, concurrency=16

       CACHE      | HITRATE |   QPS   |  HITS   | MISSES
------------------+---------+---------+---------+----------
  otter           | 51.03%  | 5841121 | 3827156 | 3672844
  sieve           | 47.67%  | 2644570 | 3575574 | 3924426
  tinylfu         | 47.37%  | 3214745 | 3552508 | 3947492
  s3-fifo         | 47.17%  | 1965924 | 3537449 | 3962551
  slru            | 46.49%  | 2942330 | 3486632 | 4013368
  s4lru           | 46.13%  | 4043127 | 3459782 | 4040218
  two-queue       | 45.49%  | 2110298 | 3411759 | 4088241
  clock           | 37.33%  | 3370787 | 2799491 | 4700509
  freelru-sharded | 36.61%  | 8038585 | 2745651 | 4754349
  lru-groupcache  | 36.57%  | 3135452 | 2742601 | 4757399
  freelru-synced  | 36.56%  | 5751534 | 2742103 | 4757897
  lru-hashicorp   | 36.56%  | 3052503 | 2741931 | 4758069


itemSize=500000, workloads=7500000, cacheSize=1.00%, zipf's alpha=0.99, concurrency=1

       CACHE      | HITRATE |   QPS    |  HITS   | MISSES
------------------+---------+----------+---------+----------
  tinylfu         | 63.94%  |  5656109 | 4795548 | 2704452
  otter           | 63.61%  |  3038898 | 4770473 | 2729527
  s3-fifo         | 63.59%  |  2843063 | 4768904 | 2731096
  sieve           | 63.33%  |  6323777 | 4750114 | 2749886
  slru            | 62.89%  |  4515352 | 4716703 | 2783297
  s4lru           | 62.68%  |  7218479 | 4701098 | 2798902
  two-queue       | 61.99%  |  3121099 | 4649213 | 2850787
  clock           | 56.12%  |  5873140 | 4208674 | 3291326
  freelru-sharded | 55.46%  | 12908778 | 4159218 | 3340782
  lru-hashicorp   | 55.37%  |  5241090 | 4153014 | 3346986
  lru-groupcache  | 55.37%  |  5060729 | 4153014 | 3346986
  freelru-synced  | 55.37%  | 12479201 | 4153014 | 3346986


itemSize=500000, workloads=7500000, cacheSize=1.00%, zipf's alpha=0.99, concurrency=2

       CACHE      | HITRATE |   QPS    |  HITS   | MISSES
------------------+---------+----------+---------+----------
  tinylfu         | 63.93%  |  3255208 | 4794994 | 2705006
  otter           | 63.60%  |  3685504 | 4769856 | 2730144
  s3-fifo         | 63.58%  |  2086811 | 4768156 | 2731844
  sieve           | 63.40%  |  2986858 | 4754832 | 2745168
  slru            | 62.87%  |  3430924 | 4715246 | 2784754
  s4lru           | 62.68%  |  4960317 | 4701063 | 2798937
  two-queue       | 61.99%  |  2365184 | 4649330 | 2850670
  clock           | 56.11%  |  4388531 | 4208616 | 3291384
  freelru-sharded | 55.46%  | 12077295 | 4159445 | 3340555
  lru-hashicorp   | 55.38%  |  3714710 | 4153562 | 3346438
  freelru-synced  | 55.37%  |  7772021 | 4153017 | 3346983
  lru-groupcache  | 55.37%  |  3720238 | 4152904 | 3347096


itemSize=500000, workloads=7500000, cacheSize=1.00%, zipf's alpha=0.99, concurrency=4

       CACHE      | HITRATE |   QPS    |  HITS   | MISSES
------------------+---------+----------+---------+----------
  tinylfu         | 63.94%  |  3069996 | 4795149 | 2704851
  otter           | 63.58%  |  3924647 | 4768239 | 2731761
  s3-fifo         | 63.57%  |  2000533 | 4768108 | 2731892
  sieve           | 63.38%  |  2378687 | 4753855 | 2746145
  slru            | 62.87%  |  3199659 | 4715194 | 2784806
  s4lru           | 62.68%  |  4157428 | 4700782 | 2799218
  two-queue       | 62.00%  |  2222881 | 4649704 | 2850296
  clock           | 56.12%  |  3678274 | 4208913 | 3291087
  freelru-sharded | 55.46%  | 14534884 | 4159525 | 3340475
  lru-hashicorp   | 55.38%  |  3324468 | 4153204 | 3346796
  freelru-synced  | 55.37%  |  5910165 | 4152932 | 3347068
  lru-groupcache  | 55.37%  |  3327418 | 4152786 | 3347214


itemSize=500000, workloads=7500000, cacheSize=1.00%, zipf's alpha=0.99, concurrency=8

       CACHE      | HITRATE |   QPS    |  HITS   | MISSES
------------------+---------+----------+---------+----------
  tinylfu         | 63.93%  |  2893519 | 4794449 | 2705551
  s3-fifo         | 63.57%  |  1982554 | 4767839 | 2732161
  sieve           | 63.40%  |  2371917 | 4754855 | 2745145
  slru            | 62.88%  |  3016895 | 4716153 | 2783847
  s4lru           | 62.67%  |  3949447 | 4700359 | 2799641
  otter           | 62.34%  |  4312823 | 4675589 | 2824411
  two-queue       | 61.99%  |  2127056 | 4649532 | 2850468
  clock           | 56.11%  |  3499767 | 4208371 | 3291629
  freelru-sharded | 55.45%  | 19788918 | 4158923 | 3341077
  lru-hashicorp   | 55.37%  |  3207870 | 4152986 | 3347014
  lru-groupcache  | 55.36%  |  3209243 | 4152253 | 3347747
  freelru-synced  | 55.36%  |  5555556 | 4152207 | 3347793


itemSize=500000, workloads=7500000, cacheSize=1.00%, zipf's alpha=0.99, concurrency=16

       CACHE      | HITRATE |   QPS    |  HITS   | MISSES
------------------+---------+----------+---------+----------
  tinylfu         | 63.94%  |  2955083 | 4795206 | 2704794
  s3-fifo         | 63.57%  |  1926535 | 4768059 | 2731941
  sieve           | 63.50%  |  2353310 | 4762580 | 2737420
  slru            | 62.88%  |  3021757 | 4715854 | 2784146
  s4lru           | 62.68%  |  3888025 | 4700723 | 2799277
  two-queue       | 61.99%  |  2202643 | 4649158 | 2850842
  otter           | 61.91%  |  4391101 | 4643488 | 2856512
  clock           | 56.11%  |  3559563 | 4207883 | 3292117
  freelru-sharded | 55.45%  | 27075812 | 4159090 | 3340910
  lru-hashicorp   | 55.38%  |  3203759 | 4153404 | 3346596
  freelru-synced  | 55.37%  |  5197505 | 4152900 | 3347100
  lru-groupcache  | 55.36%  |  3175275 | 4152140 | 3347860


itemSize=500000, workloads=7500000, cacheSize=10.00%, zipf's alpha=0.99, concurrency=1

       CACHE      | HITRATE |   QPS   |  HITS   | MISSES
------------------+---------+---------+---------+----------
  tinylfu         | 80.43%  | 4340278 | 6032039 | 1467961
  otter           | 79.86%  | 2307692 | 5989804 | 1510196
  s3-fifo         | 79.84%  | 2659574 | 5987895 | 1512105
  sieve           | 79.69%  | 6345178 | 5976378 | 1523622
  s4lru           | 78.98%  | 5438724 | 5923748 | 1576252
  two-queue       | 78.77%  | 3020540 | 5907726 | 1592274
  slru            | 78.68%  | 4019293 | 5901224 | 1598776
  clock           | 76.44%  | 6087662 | 5732671 | 1767329
  freelru-sharded | 75.82%  | 9752926 | 5686230 | 1813770
  lru-hashicorp   | 75.82%  | 5000000 | 5686182 | 1813818
  lru-groupcache  | 75.82%  | 4325260 | 5686182 | 1813818
  freelru-synced  | 75.82%  | 9640103 | 5686182 | 1813818


itemSize=500000, workloads=7500000, cacheSize=10.00%, zipf's alpha=0.99, concurrency=2

       CACHE      | HITRATE |   QPS    |  HITS   | MISSES
------------------+---------+----------+---------+----------
  tinylfu         | 80.44%  |  3106877 | 6032660 | 1467340
  otter           | 79.86%  |  3231366 | 5989857 | 1510143
  s3-fifo         | 79.84%  |  2058743 | 5987986 | 1512014
  sieve           | 79.71%  |  2703677 | 5978276 | 1521724
  s4lru           | 78.99%  |  4058442 | 5923915 | 1576085
  two-queue       | 78.78%  |  2401537 | 5908518 | 1591482
  slru            | 78.68%  |  3134141 | 5901353 | 1598647
  clock           | 76.45%  |  4385965 | 5733538 | 1766462
  freelru-sharded | 75.83%  | 11792453 | 5687600 | 1812400
  lru-groupcache  | 75.83%  |  3352705 | 5687576 | 1812424
  lru-hashicorp   | 75.83%  |  3640777 | 5687483 | 1812517
  freelru-synced  | 75.83%  |  6906077 | 5687430 | 1812570


itemSize=500000, workloads=7500000, cacheSize=10.00%, zipf's alpha=0.99, concurrency=4

       CACHE      | HITRATE |   QPS    |  HITS   | MISSES
------------------+---------+----------+---------+----------
  tinylfu         | 80.44%  |  2841986 | 6033160 | 1466840
  otter           | 79.85%  |  2399232 | 5989003 | 1510997
  s3-fifo         | 79.82%  |  1966439 | 5986817 | 1513183
  sieve           | 79.72%  |  2207181 | 5978935 | 1521065
  s4lru           | 78.98%  |  3496503 | 5923172 | 1576828
  two-queue       | 78.78%  |  2122842 | 5908180 | 1591820
  slru            | 78.68%  |  2841986 | 5900709 | 1599291
  clock           | 76.45%  |  3842213 | 5733546 | 1766454
  lru-groupcache  | 75.84%  |  3217503 | 5687651 | 1812349
  lru-hashicorp   | 75.83%  |  3363229 | 5687624 | 1812376
  freelru-synced  | 75.83%  |  5588674 | 5687445 | 1812555
  freelru-sharded | 75.82%  | 15756303 | 5686624 | 1813376


itemSize=500000, workloads=7500000, cacheSize=10.00%, zipf's alpha=0.99, concurrency=8

       CACHE      | HITRATE |   QPS    |  HITS   | MISSES
------------------+---------+----------+---------+----------
  tinylfu         | 80.45%  |  2832326 | 6033703 | 1466297
  s3-fifo         | 79.83%  |  1975764 | 5987378 | 1512622
  sieve           | 79.70%  |  2158895 | 5977574 | 1522426
  s4lru           | 78.98%  |  3358710 | 5923728 | 1576272
  two-queue       | 78.78%  |  2282410 | 5908763 | 1591237
  slru            | 78.68%  |  2824859 | 5901374 | 1598626
  otter           | 77.28%  |  4051864 | 5795666 | 1704334
  clock           | 76.44%  |  3751876 | 5733333 | 1766667
  lru-groupcache  | 75.84%  |  3157895 | 5688179 | 1811821
  freelru-synced  | 75.83%  |  4860661 | 5687323 | 1812677
  lru-hashicorp   | 75.83%  |  3343736 | 5687291 | 1812709
  freelru-sharded | 75.83%  | 22796353 | 5687119 | 1812881


itemSize=500000, workloads=7500000, cacheSize=10.00%, zipf's alpha=0.99, concurrency=16

       CACHE      | HITRATE |   QPS    |  HITS   | MISSES
------------------+---------+----------+---------+----------
  tinylfu         | 80.44%  |  2829121 | 6032692 | 1467308
  s3-fifo         | 79.83%  |  1956692 | 5987605 | 1512395
  sieve           | 79.71%  |  2166378 | 5978372 | 1521628
  s4lru           | 78.98%  |  3276540 | 5923665 | 1576335
  two-queue       | 78.78%  |  2211085 | 5908389 | 1591611
  slru            | 78.69%  |  2789141 | 5901390 | 1598610
  otter           | 76.95%  |  3616201 | 5771458 | 1728542
  clock           | 76.45%  |  3757515 | 5733591 | 1766409
  freelru-sharded | 75.83%  | 32051282 | 5687085 | 1812915
  freelru-synced  | 75.83%  |  3718394 | 5686961 | 1813039
  lru-hashicorp   | 75.82%  |  3265128 | 5686305 | 1813695
  lru-groupcache  | 75.82%  |  3123698 | 5686208 | 1813792