From 833cf082dac0b8296ba4b41935e15196b5210abe Mon Sep 17 00:00:00 2001 From: Jakub Jirutka Date: Sun, 7 May 2023 00:51:31 +0200 Subject: Remove unnecessary/unused "timeago" features To decrease dependency bloat and binary size. --- src/garage/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/garage/Cargo.toml b/src/garage/Cargo.toml index 0cbdf890..c8f87560 100644 --- a/src/garage/Cargo.toml +++ b/src/garage/Cargo.toml @@ -33,7 +33,7 @@ garage_web = { version = "0.8.2", path = "../web" } backtrace = "0.3" bytes = "1.0" bytesize = "1.1" -timeago = "0.4" +timeago = { version = "0.4", default-features = false } parse_duration = "2.1" hex = "0.4" tracing = { version = "0.1" } -- cgit v1.2.3 From 6d3ace1ea9561386bb89b0a3e66b881e8e7be5e4 Mon Sep 17 00:00:00 2001 From: Jakub Jirutka Date: Sun, 7 May 2023 17:01:11 +0200 Subject: Fix undefined macro warn! on 32-bit Compiling garage_db v0.8.2 (garage-0.8.2/src/db) error: cannot find macro `warn` in this scope --> src/db/lmdb_adapter.rs:352:2 | 352 | warn!("LMDB is not recommended on 32-bit systems, database size will be limited"); | ^^^^ | = help: consider importing this macro: tracing::warn = note: `warn` is in scope, but it is an attribute: `#[warn]` error: could not compile `garage_db` due to previous error --- src/db/lmdb_adapter.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/db/lmdb_adapter.rs b/src/db/lmdb_adapter.rs index 31956612..ecbc3b81 100644 --- a/src/db/lmdb_adapter.rs +++ b/src/db/lmdb_adapter.rs @@ -349,6 +349,6 @@ pub fn recommended_map_size() -> usize { #[cfg(target_pointer_width = "32")] pub fn recommended_map_size() -> usize { - warn!("LMDB is not recommended on 32-bit systems, database size will be limited"); + tracing::warn!("LMDB is not recommended on 32-bit systems, database size will be limited"); 1usize << 30 } -- cgit v1.2.3 From d2deee0b8bc22de5e8f1115f65a8a979b1beba18 Mon Sep 17 00:00:00 2001 From: Jakub Jirutka Date: Sun, 7 May 2023 18:12:01 +0200 Subject: Declare garage crates using workspace.dependencies This will allow to really disable "sled" feature without declaring `default-features = false` in every Cargo.toml where garage_db and garage_model is used. See https://doc.rust-lang.org/cargo/reference/workspaces.html#the-dependencies-table --- src/api/Cargo.toml | 10 +++++----- src/block/Cargo.toml | 8 ++++---- src/garage/Cargo.toml | 16 ++++++++-------- src/k2v-client/Cargo.toml | 2 +- src/model/Cargo.toml | 10 +++++----- src/rpc/Cargo.toml | 2 +- src/table/Cargo.toml | 6 +++--- src/util/Cargo.toml | 2 +- src/web/Cargo.toml | 8 ++++---- 9 files changed, 32 insertions(+), 32 deletions(-) (limited to 'src') diff --git a/src/api/Cargo.toml b/src/api/Cargo.toml index 9babec02..747f70ab 100644 --- a/src/api/Cargo.toml +++ b/src/api/Cargo.toml @@ -14,11 +14,11 @@ path = "lib.rs" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -garage_model = { version = "0.8.2", path = "../model" } -garage_table = { version = "0.8.2", path = "../table" } -garage_block = { version = "0.8.2", path = "../block" } -garage_util = { version = "0.8.2", path = "../util" } -garage_rpc = { version = "0.8.2", path = "../rpc" } +garage_model.workspace = true +garage_table.workspace = true +garage_block.workspace = true +garage_util.workspace = true +garage_rpc.workspace = true async-trait = "0.1.7" base64 = "0.21" diff --git a/src/block/Cargo.toml b/src/block/Cargo.toml index c6985754..3bf1c40a 100644 --- a/src/block/Cargo.toml +++ b/src/block/Cargo.toml @@ -14,10 +14,10 @@ path = "lib.rs" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -garage_db = { version = "0.8.2", path = "../db" } -garage_rpc = { version = "0.8.2", path = "../rpc" } -garage_util = { version = "0.8.2", path = "../util" } -garage_table = { version = "0.8.2", path = "../table" } +garage_db.workspace = true +garage_rpc.workspace = true +garage_util.workspace = true +garage_table.workspace = true opentelemetry = "0.17" diff --git a/src/garage/Cargo.toml b/src/garage/Cargo.toml index c8f87560..9935ce10 100644 --- a/src/garage/Cargo.toml +++ b/src/garage/Cargo.toml @@ -21,14 +21,14 @@ path = "tests/lib.rs" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -garage_db = { version = "0.8.2", path = "../db" } -garage_api = { version = "0.8.2", path = "../api" } -garage_block = { version = "0.8.2", path = "../block" } -garage_model = { version = "0.8.2", path = "../model" } -garage_rpc = { version = "0.8.2", path = "../rpc" } -garage_table = { version = "0.8.2", path = "../table" } -garage_util = { version = "0.8.2", path = "../util" } -garage_web = { version = "0.8.2", path = "../web" } +garage_db.workspace = true +garage_api.workspace = true +garage_block.workspace = true +garage_model.workspace = true +garage_rpc.workspace = true +garage_table.workspace = true +garage_util.workspace = true +garage_web.workspace = true backtrace = "0.3" bytes = "1.0" diff --git a/src/k2v-client/Cargo.toml b/src/k2v-client/Cargo.toml index 52c16d89..27e85651 100644 --- a/src/k2v-client/Cargo.toml +++ b/src/k2v-client/Cargo.toml @@ -23,7 +23,7 @@ tokio = "1.24" # cli deps clap = { version = "4.1", optional = true, features = ["derive", "env"] } -garage_util = { version = "0.8.2", path = "../util", optional = true } +garage_util = { workspace = true, optional = true } [features] diff --git a/src/model/Cargo.toml b/src/model/Cargo.toml index 2b525a42..6dc954d4 100644 --- a/src/model/Cargo.toml +++ b/src/model/Cargo.toml @@ -14,11 +14,11 @@ path = "lib.rs" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -garage_db = { version = "0.8.2", default-features = false, path = "../db" } -garage_rpc = { version = "0.8.2", path = "../rpc" } -garage_table = { version = "0.8.2", path = "../table" } -garage_block = { version = "0.8.2", path = "../block" } -garage_util = { version = "0.8.2", path = "../util" } +garage_db.workspace = true +garage_rpc.workspace = true +garage_table.workspace = true +garage_block.workspace = true +garage_util.workspace = true async-trait = "0.1.7" arc-swap = "1.0" diff --git a/src/rpc/Cargo.toml b/src/rpc/Cargo.toml index dcf44f4a..f0fde7a7 100644 --- a/src/rpc/Cargo.toml +++ b/src/rpc/Cargo.toml @@ -14,7 +14,7 @@ path = "lib.rs" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -garage_util = { version = "0.8.2", path = "../util" } +garage_util.workspace = true arc-swap = "1.0" bytes = "1.0" diff --git a/src/table/Cargo.toml b/src/table/Cargo.toml index c794c924..d0776945 100644 --- a/src/table/Cargo.toml +++ b/src/table/Cargo.toml @@ -14,9 +14,9 @@ path = "lib.rs" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -garage_db = { version = "0.8.2", path = "../db" } -garage_rpc = { version = "0.8.2", path = "../rpc" } -garage_util = { version = "0.8.2", path = "../util" } +garage_db.workspace = true +garage_rpc.workspace = true +garage_util.workspace = true opentelemetry = "0.17" diff --git a/src/util/Cargo.toml b/src/util/Cargo.toml index 2e6231f6..08fb5553 100644 --- a/src/util/Cargo.toml +++ b/src/util/Cargo.toml @@ -14,7 +14,7 @@ path = "lib.rs" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -garage_db = { version = "0.8.2", path = "../db" } +garage_db.workspace = true arc-swap = "1.0" async-trait = "0.1" diff --git a/src/web/Cargo.toml b/src/web/Cargo.toml index d0a23af4..423d3829 100644 --- a/src/web/Cargo.toml +++ b/src/web/Cargo.toml @@ -14,10 +14,10 @@ path = "lib.rs" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -garage_api = { version = "0.8.2", path = "../api" } -garage_model = { version = "0.8.2", path = "../model" } -garage_util = { version = "0.8.2", path = "../util" } -garage_table = { version = "0.8.2", path = "../table" } +garage_api.workspace = true +garage_model.workspace = true +garage_util.workspace = true +garage_table.workspace = true err-derive = "0.3" tracing = "0.1" -- cgit v1.2.3 From 9c788059e2335fb9d1a145ce3b6a64070a54a202 Mon Sep 17 00:00:00 2001 From: Jonathan Davies Date: Mon, 8 May 2023 18:57:10 +0100 Subject: block/manager.rs: In is_block_compressed - check which compression_level is configured on a node and check for raw block first if compression is disabled (to help reduce syscalls during a scrub). --- src/block/manager.rs | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/block/manager.rs b/src/block/manager.rs index 26278974..3ece9a8a 100644 --- a/src/block/manager.rs +++ b/src/block/manager.rs @@ -600,12 +600,32 @@ impl BlockManager { /// Utility: check if block is stored compressed. Error if block is not stored async fn is_block_compressed(&self, hash: &Hash) -> Result { let mut path = self.block_path(hash); - path.set_extension("zst"); - if fs::metadata(&path).await.is_ok() { - return Ok(true); + + // If compression is disabled on node - check for the raw block + // first and then a compressed one (as compression may have been + // previously enabled). + match self.compression_level { + None => { + if fs::metadata(&path).await.is_ok() { + return Ok(false); + } + + path.set_extension("zst"); + + fs::metadata(&path).await.map(|_| true).map_err(Into::into) + } + _ => { + path.set_extension("zst"); + + if fs::metadata(&path).await.is_ok() { + return Ok(true); + } + + path.set_extension(""); + + fs::metadata(&path).await.map(|_| false).map_err(Into::into) + } } - path.set_extension(""); - fs::metadata(&path).await.map(|_| false).map_err(Into::into) } async fn lock_mutate(&self, hash: &Hash) -> MutexGuard<'_, BlockManagerLocked> { -- cgit v1.2.3 From 9e0a9c1c15cc8a6849de8c23bc1b0e711ab4fc8f Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Wed, 3 May 2023 16:43:08 +0200 Subject: move git-version dependency to main crate to reduce rebuilds --- src/garage/Cargo.toml | 1 + src/garage/main.rs | 6 ++++++ src/util/Cargo.toml | 1 - src/util/version.rs | 12 ++++-------- 4 files changed, 11 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/garage/Cargo.toml b/src/garage/Cargo.toml index 9935ce10..2b366ff1 100644 --- a/src/garage/Cargo.toml +++ b/src/garage/Cargo.toml @@ -41,6 +41,7 @@ tracing-subscriber = { version = "0.3", features = ["env-filter"] } rand = "0.8" async-trait = "0.1.7" sodiumoxide = { version = "0.2.5-0", package = "kuska-sodiumoxide" } +git-version = "0.3.4" serde = { version = "1.0", default-features = false, features = ["derive", "rc"] } serde_bytes = "0.11" diff --git a/src/garage/main.rs b/src/garage/main.rs index 1ab18bb2..e8aee892 100644 --- a/src/garage/main.rs +++ b/src/garage/main.rs @@ -108,6 +108,12 @@ async fn main() { ][..]; if let Some(git_version) = option_env!("GIT_VERSION") { garage_util::version::init_version(git_version); + } else { + garage_util::version::init_version(git_version::git_version!( + prefix = "git:", + cargo_prefix = "cargo:", + fallback = "unknown" + )); } garage_util::version::init_features(features); diff --git a/src/util/Cargo.toml b/src/util/Cargo.toml index 08fb5553..f72051b9 100644 --- a/src/util/Cargo.toml +++ b/src/util/Cargo.toml @@ -22,7 +22,6 @@ blake2 = "0.10" bytes = "1.0" digest = "0.10" err-derive = "0.3" -git-version = "0.3.4" hexdump = "0.1" xxhash-rust = { version = "0.8", default-features = false, features = ["xxh3"] } hex = "0.4" diff --git a/src/util/version.rs b/src/util/version.rs index 2b2ea271..19907ed1 100644 --- a/src/util/version.rs +++ b/src/util/version.rs @@ -1,18 +1,14 @@ use std::sync::Arc; -use arc_swap::{ArcSwap, ArcSwapOption}; +use arc_swap::ArcSwapOption; lazy_static::lazy_static! { - static ref VERSION: ArcSwap<&'static str> = ArcSwap::new(Arc::new(git_version::git_version!( - prefix = "git:", - cargo_prefix = "cargo:", - fallback = "unknown" - ))); + static ref VERSION: ArcSwapOption<&'static str> = ArcSwapOption::new(None); static ref FEATURES: ArcSwapOption<&'static [&'static str]> = ArcSwapOption::new(None); } pub fn garage_version() -> &'static str { - &VERSION.load() + VERSION.load().as_ref().unwrap() } pub fn garage_features() -> Option<&'static [&'static str]> { @@ -20,7 +16,7 @@ pub fn garage_features() -> Option<&'static [&'static str]> { } pub fn init_version(version: &'static str) { - VERSION.store(Arc::new(version)); + VERSION.store(Some(Arc::new(version))); } pub fn init_features(features: &'static [&'static str]) { -- cgit v1.2.3