From 59028924a275e6d5c34230262dfd3686b723ce65 Mon Sep 17 00:00:00 2001 From: phil Date: Tue, 12 Aug 2025 15:36:08 -0400 Subject: [PATCH] use git-main fjall for weak delete --- Cargo.lock | 31 +++++++++++++++---------------- ufos/Cargo.toml | 2 +- ufos/src/storage_fjall.rs | 7 ++++++- 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3f51793..e9cda1e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1220,7 +1220,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "18e4fdb82bd54a12e42fb58a800dcae6b9e13982238ce2296dc3570b92148e1f" dependencies = [ "data-encoding", - "syn 2.0.103", + "syn 1.0.109", ] [[package]] @@ -1569,7 +1569,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "976dd42dc7e85965fe702eb8164f21f450704bdde31faefd6471dba214cb594e" dependencies = [ "libc", - "windows-sys 0.59.0", + "windows-sys 0.52.0", ] [[package]] @@ -1611,9 +1611,8 @@ dependencies = [ [[package]] name = "fjall" -version = "2.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26b2ced3483989a62b3533c9f99054d73b527c6c0045cf22b00fe87956f1a46f" +version = "2.11.2" +source = "git+https://github.com/fjall-rs/fjall.git#42d811f7c8cc9004407d520d37d2a1d8d246c03d" dependencies = [ "byteorder", "byteview", @@ -2595,7 +2594,7 @@ checksum = "e04d7f318608d35d4b61ddd75cbdaee86b023ebe2bd5a66ee0915f0bf93095a9" dependencies = [ "hermit-abi", "libc", - "windows-sys 0.59.0", + "windows-sys 0.52.0", ] [[package]] @@ -2800,7 +2799,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc2f4eb4bc735547cfed7c0a4922cbd04a4655978c09b54f1f7b228750664c34" dependencies = [ "cfg-if", - "windows-targets 0.52.6", + "windows-targets 0.48.5", ] [[package]] @@ -2931,9 +2930,9 @@ checksum = "112b39cec0b298b6c1999fee3e31427f74f676e4cb9879ed1a121b43661a4154" [[package]] name = "lsm-tree" -version = "2.8.0" +version = "2.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0a63a5e98a38b51765274137d8aedfbd848da5f4d016867e186b673fcc06a8c" +checksum = "55b6d7475a8dd22e749186968daacf8e2a77932b061b1bd263157987bbfc0c6c" dependencies = [ "byteorder", "crossbeam-skiplist", @@ -4054,7 +4053,7 @@ dependencies = [ "once_cell", "socket2 0.5.9", "tracing", - "windows-sys 0.59.0", + "windows-sys 0.52.0", ] [[package]] @@ -4436,7 +4435,7 @@ dependencies = [ "errno", "libc", "linux-raw-sys 0.4.15", - "windows-sys 0.59.0", + "windows-sys 0.52.0", ] [[package]] @@ -4449,7 +4448,7 @@ dependencies = [ "errno", "libc", "linux-raw-sys 0.9.4", - "windows-sys 0.59.0", + "windows-sys 0.52.0", ] [[package]] @@ -5188,7 +5187,7 @@ dependencies = [ "getrandom 0.3.3", "once_cell", "rustix 1.0.5", - "windows-sys 0.59.0", + "windows-sys 0.52.0", ] [[package]] @@ -5821,9 +5820,9 @@ checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65" [[package]] name = "value-log" -version = "1.8.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd29b17c041f94e0885179637289815cd038f0c9fc19c4549d5a97017404fb7d" +checksum = "62fc7c4ce161f049607ecea654dca3f2d727da5371ae85e2e4f14ce2b98ed67c" dependencies = [ "byteorder", "byteview", @@ -6073,7 +6072,7 @@ version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" dependencies = [ - "windows-sys 0.59.0", + "windows-sys 0.48.0", ] [[package]] diff --git a/ufos/Cargo.toml b/ufos/Cargo.toml index ec22d3b..bbabe69 100644 --- a/ufos/Cargo.toml +++ b/ufos/Cargo.toml @@ -13,7 +13,7 @@ chrono = { version = "0.4.41", features = ["serde"] } clap = { version = "4.5.31", features = ["derive"] } dropshot = "0.16.0" env_logger = "0.11.7" -fjall = { version = "2.8.0", features = ["lz4"] } +fjall = { git = "https://github.com/fjall-rs/fjall.git", features = ["lz4"] } getrandom = "0.3.3" http = "1.3.1" jetstream = { path = "../jetstream", features = ["metrics"] } diff --git a/ufos/src/storage_fjall.rs b/ufos/src/storage_fjall.rs index 4e88844..87edafb 100644 --- a/ufos/src/storage_fjall.rs +++ b/ufos/src/storage_fjall.rs @@ -1619,7 +1619,12 @@ impl StoreBackground for FjallBackground { histogram!("storage_trim_dirty_nsids").record(completed.len() as f64); histogram!("storage_trim_duration").record(dt.as_micros() as f64); counter!("storage_trim_removed", "dangling" => "true").increment(total_danglers as u64); - counter!("storage_trim_removed", "dangling" => "false").increment((total_deleted - total_danglers) as u64); + if total_deleted >= total_danglers { + counter!("storage_trim_removed", "dangling" => "false").increment((total_deleted - total_danglers) as u64); + } else { + // TODO: probably think through what's happening here + log::warn!("weird trim case: more danglers than deleted? metric will be missing for dangling=false. deleted={total_deleted} danglers={total_danglers}"); + } for c in completed { dirty_nsids.remove(&c); } -- 2.43.0 From 11d04045e141146374aef8d8d180e29a40c94e2d Mon Sep 17 00:00:00 2001 From: phil Date: Tue, 12 Aug 2025 16:14:11 -0400 Subject: [PATCH] use remove_weak for secondary rank indexes *hopefully* reduces write amplification, read amplification, space amplification, and maybe even compaction stalls? --- ufos/src/storage_fjall.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ufos/src/storage_fjall.rs b/ufos/src/storage_fjall.rs index 87edafb..d93795f 100644 --- a/ufos/src/storage_fjall.rs +++ b/ufos/src/storage_fjall.rs @@ -1222,7 +1222,8 @@ impl FjallWriter { AllTimeRecordsKey::new(new_creates_count.into(), &nsid).to_db_bytes()?, ), }; - batch.remove(&self.rollups, &old_k); // TODO: when fjall gets weak delete, this will hopefully work way better + // remove_weak is allowed here because the secondary ranking index only ever inserts once at a key + batch.remove_weak(&self.rollups, &old_k); batch.insert(&self.rollups, &new_k, ""); } @@ -1246,7 +1247,8 @@ impl FjallWriter { AllTimeDidsKey::new(new_dids_estimate.into(), &nsid).to_db_bytes()?, ), }; - batch.remove(&self.rollups, &old_k); // TODO: when fjall gets weak delete, this will hopefully work way better + // remove_weak is allowed here because the secondary ranking index only ever inserts once at a key + batch.remove_weak(&self.rollups, &old_k); batch.insert(&self.rollups, &new_k, ""); } -- 2.43.0