-
Notifications
You must be signed in to change notification settings - Fork 251
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
accounts-db: Benchmark cache evictions #4045
base: master
Are you sure you want to change the base?
Conversation
100c57d
to
8206e16
Compare
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.
Looks great! Left some comments
2766162
to
42ca375
Compare
e50fa20
to
ba708a3
Compare
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.
I think the benches look good to me. Can you share some results? I'm interested 😸
2bf4cd2
to
f3b9d49
Compare
Here we go with the results. 🙂
|
The already existing `concurrent_{read,scan}_write` benchmarks are not sufficient for benchmarking the eviction and evaluating what kind of eviction policy performs the best, because they don't fill up the cache, so eviction never happens. Add a new benchmark, which starts measuring the concurrent reads and writes on a full cache.
f3b9d49
to
42761bd
Compare
/// Sizes of accounts. | ||
/// | ||
/// - No data. | ||
/// - 165 bytes (a token account). | ||
/// - 200 bytes (a stake account). | ||
/// - 256 kibibytes (pathological case for the scan buffer). | ||
/// - 10 mebibytes (the max size for an account). | ||
const DATA_SIZES: &[usize] = &[ | ||
0, | ||
165, | ||
200, | ||
SCAN_BUFFER_SIZE_WITHOUT_DATA, | ||
MAX_PERMITTED_DATA_LENGTH as usize, | ||
]; |
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.
I like the idea of reusing this, but SCAN_BUFFER_SIZE_WITHOUT_DATA is implementation detail that's really only meant for append vec file io benchmarking. IOW, I don't think it makes sense to use that value here.
I somewhat less opposed to maintaining mostly-similar-but-actually-different values for DATA_SIZES and WEIGHTS, as they may be (are) specific to individual benches.
Another point is this comment:
/// - 256 kibibytes (pathological case for the scan buffer).
Before this was within the bench that was benchmarking the scan_pubkeys()
function, so it was clear what the "scan buffer" was referring to. Now, here in a shared constant, the meaning of the scan buffer is lost.
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.
Should this file be removed?
let mut rng = SmallRng::seed_from_u64(i as u64); | ||
while !stop_threads.load(Ordering::Relaxed) { | ||
let pubkey = pubkeys.choose(&mut rng).unwrap(); | ||
test::black_box(cache.load(*pubkey, slot)); |
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.
Can we use std::hint::black_box
instead?
(And maybe we can now remove the #![feature(test)]
and extern crate test
now?)
// Prepare initial accounts, enough of the to fill up the cache. | ||
let accounts: Vec<_> = utils::accounts_with_size_limit( | ||
255, | ||
AccountsDb::DEFAULT_MAX_READ_ONLY_CACHE_DATA_SIZE_HI * 10, |
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.
Why 10x here? Would a smaller value—like 2x—work?
AccountsDb::DEFAULT_MAX_READ_ONLY_CACHE_DATA_SIZE_LO, | ||
AccountsDb::DEFAULT_MAX_READ_ONLY_CACHE_DATA_SIZE_HI, |
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.
With both low and high watermarks, the cache won't need to evict on every store. Using the same value for both is closer. But will different data sizes, we still may not evict every time. However, since the evictor thread only wakes up periodically, it is probable that the benchmark would be able to store enough into the cache such that the evictor will evict every time it wakes up.
The already existing
concurrent_{read,scan}_write
benchmarks are not sufficient for benchmarking the eviction and evaluating what kind of eviction policy performs the best, because they don't fill up the cache, so eviction never happens.Add a new benchmark, which starts measuring the concurrent reads and writes on a full cache.