allegro / bigcache

Efficient cache for gigabytes of data written in Go.
http://allegro.tech/2016/03/writing-fast-cache-service-in-go.html
Apache License 2.0
7.45k stars 593 forks source link

Get multiple cached values #379

Open raeidish opened 10 months ago

raeidish commented 10 months ago

Closes #324

It works but it's not always faster, the sweet spot where the multi is faster seems to be using 512 shards. I tried using batches and getting all keys at once.

raeidish commented 10 months ago

if you find anyway to improve it please let me know! i tried a few things but can't seem to get it faster. @cristaloleg, @janisz

raeidish commented 10 months ago

I forgot to add the locked shard to the map fixing it made a big difference

codecov-commenter commented 10 months ago

Codecov Report

Merging #379 (e894b71) into main (58fe2d2) will increase coverage by 0.85%. The diff coverage is 100.00%.

:exclamation: Current head e894b71 differs from pull request most recent head c366663. Consider uploading reports for the commit c366663 to get more accurate results

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #379      +/-   ##
==========================================
+ Coverage   88.66%   89.52%   +0.85%     
==========================================
  Files          15       15              
  Lines         794      821      +27     
==========================================
+ Hits          704      735      +31     
+ Misses         76       73       -3     
+ Partials       14       13       -1     
Files Coverage Δ
bigcache.go 94.07% <100.00%> (+1.11%) :arrow_up:
shard.go 92.10% <100.00%> (+1.61%) :arrow_up:

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 58fe2d2...c366663. Read the comment docs.

raeidish commented 10 months ago

Got a bit of a locking issue, when stats is enabled the shard tries to wlock but as it is now it’s already rlocked. This causes a deadlock issue, I’m thinking about moving the hit call outside getWithoutLock.

raeidish commented 10 months ago

seems like my test was failing because it was too big for the github action :slightly_smiling_face: looks ok now though.

raeidish commented 10 months ago

This is ready for another review :slightly_smiling_face: @janisz