-
-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Drop evicted entries immediately #169
Conversation
- Call the `flush` method of `crossbeam_epoch::Guard` when necessary. - Temporary add a crate feature `flush` to enable and disable calling the `flush`.
- Compile the test program only when `sync` feature is enabled. - Use `AtomicU32` instead of `AtomicU64` in the test program because some target platforms do not support `AtomicU64`.
Avoid compile errors in the test program when `sync` feature is disabled.
Call the `flush` method of `crossbeam_epoch::Guard` when necessary.
clippy 0.1.63 (efd358333ac 2022-07-16)
- Add unit tests. - Update the entry_lifecycle example.
Remove the temporary crate feature `flush` to make the calls on the `flush` method of `crossbeam_epoch::Guard` always enabled.
Remove the temporary crate feature `flush`. (Forgot to check Cargo.toml in)
Remove a temporary example program.
Attempt to stabilize a test `drop_value_immediately_after_eviction` for `sync::SegmentedCache`.
Attempt to stabilize a test `drop_value_immediately_after_eviction` for `sync::SegmentedCache`.
Attempt to stabilize a test `drop_value_immediately_after_eviction` for `future::Cache` on QEMU user mode emulators.
I ran some performance tests using mokabench with ARC-S3 workload.
As expected, this change added some performance overheads:
I think the overheads will be acceptable for real-world workloads. Those workloads will be much lighter than both 1. and 2, so the overhead will be much smaller. Here is a summary of when
The above benchmark runs all |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By some reason, this PR did not pick one last commit: b2c244d
Merging anyway.
Changes
This PR makes
sync
andfuture
caches to drop the value part of evicted entries immediately. It calls theflush
method ofcrossbeam_epoch::Guard
when necessary.There is no change in the public API.
Background
moka::cht
uses crossbeam-epoch'sdefer_unchecked
method, which takes a closure as the argument, to drop evicted entries. However, to improve the throughput, crossbeam-epoch will stash these deferred functions away in thread local storage until it gets an enough number of them (62 for each thread). They do not get executed until they are pushed to the global queue.So, if client has
N
threads calling Moka's write methods (insert
,get_with
,invalidate
, etc.), crossbeam-epoch can delay dropping evicted/invalidated entries up toN * (62 - 1)
entries.This PR ensures that these deferred functions will be executed as soon as possible by calling the
flush
method ofcrossbeam_epoch::Guard
in a timely manner.