foyer-rs / foyer

Hybrid in-memory and disk cache in Rust
https://foyer.rs
Apache License 2.0
291 stars 20 forks source link

refactor: refine small object disk cache #761

Closed MrCroxx closed 2 weeks ago

MrCroxx commented 2 weeks ago

What's changed and what's your intention?

Please explain IN DETAIL what the changes are in this PR and why they are needed. :D

FYI: #759

Lock Order:

load (async set cache, not good):

                                                                  |------------ requires async mutex -------------|
 lock(R) bloom filter => unlock(R) bloom filter => lock(R) set => lock(e) set cache => load => unlock(e) set cache => unlock(r) set

load (sync set cache, good):

 lock(R) bloom filter => unlock(R) bloom filter => lock(R) set => lock(e) set cache => unlock(e) set cache => load => lock(e) set cache => unlock(e) set cache => unlock(r) set

update:

 lock(W) set => lock(e) set cache => invalid set cache => unlock(e) set cache => update set => lock(w) bloom filter => unlock(w) bloom filter => unlock(w) set

Checklist

Related issues or PRs (optional)

close #759

codecov[bot] commented 2 weeks ago

Codecov Report

Attention: Patch coverage is 89.62264% with 11 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
foyer-storage/src/small/set_manager.rs 92.18% 5 Missing :warning:
foyer-storage/src/store.rs 42.85% 4 Missing :warning:
foyer-storage/src/small/generic.rs 66.66% 2 Missing :warning:
Files with missing lines Coverage Δ
foyer-storage/src/small/flusher.rs 85.00% <100.00%> (-0.30%) :arrow_down:
foyer-storage/src/small/set.rs 94.15% <ø> (-0.02%) :arrow_down:
foyer-storage/src/small/set_cache.rs 100.00% <100.00%> (ø)
foyer-storage/src/small/generic.rs 75.14% <66.66%> (+0.52%) :arrow_up:
foyer-storage/src/store.rs 85.33% <42.85%> (-0.73%) :arrow_down:
foyer-storage/src/small/set_manager.rs 90.28% <92.18%> (+1.96%) :arrow_up: