-
Notifications
You must be signed in to change notification settings - Fork 49
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
Add support to disable record cache #2034
Conversation
@@ -122,7 +122,12 @@ impl<T: TransportConnect> ReplicatedLogletProvider<T> { | |||
_metadata_store_client: metadata_store_client, | |||
networking, | |||
// todo(asoli): read memory budget from ReplicatedLogletOptions |
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 we remove the todo then?
.max_capacity(memory_budget_bytes.try_into().unwrap_or(u64::MAX)) | ||
.eviction_policy(EvictionPolicy::lru()) | ||
.build(); | ||
/// Creates a new instance of RecordCache. If memory budges is None |
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.
/// Creates a new instance of RecordCache. If memory budges is None | |
/// Creates a new instance of RecordCache. If memory budget is None |
crates/types/src/config/bifrost.rs
Outdated
@@ -237,6 +237,13 @@ pub struct ReplicatedLogletOptions { | |||
/// | |||
/// Retry policy for log server RPCs | |||
pub log_server_retry_policy: RetryPolicy, | |||
|
|||
/// records_cache_memory_budget_bytes |
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.
/// records_cache_memory_budget_bytes | |
/// # In-memory RecordCache memory limit |
crates/types/src/config/bifrost.rs
Outdated
/// Optional size of records cache in bytes. | ||
/// If set to None, records cache will be disabled. | ||
/// Defaults: 20M | ||
pub records_cache_memory_budget_bytes: Option<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.
pub records_cache_memory_budget_bytes: Option<usize>, | |
pub record_cache_memory_size: Option<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.
Can you look at common.rs's configuration for inspiration? For configuration keys that accept bytes, we have some helpers to allow setting those values from human-friendly strings. A good example is rocksdb_total_memory_size
crates/types/src/config/bifrost.rs
Outdated
|
||
/// records_cache_memory_budget_bytes | ||
/// | ||
/// Optional size of records cache in bytes. |
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.
/// Optional size of records cache in bytes. | |
/// Optional size of record cache in bytes. |
crates/types/src/config/bifrost.rs
Outdated
@@ -257,6 +264,7 @@ impl Default for ReplicatedLogletOptions { | |||
Some(10), | |||
Some(Duration::from_millis(2000)), | |||
), | |||
records_cache_memory_budget_bytes: Some(20_000_000), // 20MB |
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.
records_cache_memory_budget_bytes: Some(20_000_000), // 20MB | |
record_cache_memory_size: Some(20_000_000), // 20MB |
711100a
to
ab2bf21
Compare
crates/types/src/config/bifrost.rs
Outdated
/// If set to None, record cache will be disabled. | ||
/// Defaults: 20M | ||
#[cfg_attr(feature = "schemars", schemars(with = "NonZeroByteCount"))] | ||
pub record_cache_memory_size: Option<NonZeroByteCount>, |
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.
toml format doesn't support nulls, so we can't unset this from the configuration file. Perhaps we should allow this to be disabled by setting the size to zero instead.
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.
Ah okay, good point. I wasn't sure if I should use None, or 0 as the value to disable the cache.
Summary: Since record cache will be used in multiple places. It's possible to disable it by setting the memory budget to None. This way code can still use the cache normally but no records will be cached. All calls to Get will always return None if cache is disabled
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.
🚢 🚢 🚢 🚢
Add support to disable record cache
Summary:
Since record cache will be used in multiple places. It's possible
to disable it by setting the memory budget to None. This way code
can still use the cache normally but no records will be cached.
All calls to Get will always return None if cache is disabled