Skip to content

Commit 3b7b009

Browse files
HammadBcodetheweb
andauthored
[ENH] Upgrade to foyer 0.20.1 to support multi-disk (#5887)
## Description of changes _Summarize the changes made by this PR._ - Improvements / New functionality - Supports multi disk configuration on foyer. - Derived from #5877 but notable improvements: 1. Actually tests the new behavior and adds logic to make it work in the various parsing configurations. 2. Adds .with_direct() flag to match previous behavior. This was missed in #5877 3. Adds support for clap parsing an empty default value, this ensures memory cache which does not need this argument can be created without needing to be specified. clap(skip) has the same behavior but this is more explicit and thus preferred. The string parsing should tolerate empty paths, whitespaces other misc formatting issues. 4. More helpful and descriptive error messages 5. Supports the legacy capacity: case since we now flatten capacity into the root. And adds tests for this - Read through foyer implementation to confirm no other regressions. ## Test plan _How are these changes tested?_ I have test legacy config, clap parsing of new config, the new multi disk config with single disks, and the config with multiple disks. - [x] Tests pass locally with `pytest` for python, `yarn test` for js, `cargo test` for rust ## Migration plan No migration should be required since we handle the legacy case. ## Observability plan None ## Documentation Changes None --------- Co-authored-by: Max Isom <[email protected]>
1 parent ec4af77 commit 3b7b009

File tree

8 files changed

+416
-139
lines changed

8 files changed

+416
-139
lines changed

Cargo.lock

Lines changed: 38 additions & 69 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/cache/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ path = "src/lib.rs"
88

99
[dependencies]
1010
clap = { workspace = true }
11-
foyer = { version = "0.17.3", features = ["tracing", "serde"] }
12-
mixtrics = { version = "0.1.0", features = ["opentelemetry_0_27"] }
11+
foyer = { version = "0.20.1", features = ["tracing", "serde"] }
12+
mixtrics = { version = "0.2.3", features = ["opentelemetry_0_27"] }
1313
anyhow = "1.0"
1414
opentelemetry = { version = "0.27.0", default-features = false, features = ["trace", "metrics"] }
1515

rust/cache/src/bin/cops-disk-cache-config-writer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use chroma_cache::{CacheConfig, FoyerCacheConfig};
66

77
fn main() {
88
let config = FoyerCacheConfig::parse();
9-
if config.dir.is_none() {
9+
if config.disks().is_empty() {
1010
panic!("Disk cache is required for disk cache config writer");
1111
}
1212
let out = serde_yaml::to_string(&CacheConfig::Disk(config)).unwrap();

rust/cache/src/bin/cops-memory-cache-config-writer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
33
use clap::Parser;
44

5-
use chroma_cache::{CacheConfig, FoyerCacheConfig};
5+
use chroma_cache::{CacheConfig, DiskFieldValue, FoyerCacheConfig};
66

77
fn main() {
88
let mut config = FoyerCacheConfig::parse();
9-
config.dir = None;
9+
config.disk = DiskFieldValue::MultiDisk(vec![]);
1010
let out = serde_yaml::to_string(&CacheConfig::Memory(config)).unwrap();
1111
print!("{out}");
1212
}

0 commit comments

Comments
 (0)