Skip to content

Commit 1edffd6

Browse files
committed
feat: Expose gix-pack caching features
1 parent 677de22 commit 1edffd6

File tree

4 files changed

+22
-7
lines changed

4 files changed

+22
-7
lines changed

gix/Cargo.toml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ required-features = ["blocking-network-client"]
2424

2525
[features]
2626

27-
default = ["max-performance-safe", "comfort", "basic", "extras"]
27+
default = ["max-performance-safe", "comfort", "basic", "extras", "gix-pack-object-cache-dynamic"]
2828

2929
#! There are various categories of features which help to optimize performance and build times. `gix` comes with 'batteries included' and everything is
3030
#! enabled as long as it doesn't sacrifice compatibility. Most users will be fine with that but will pay with higher compile times than necessary as they
@@ -304,6 +304,18 @@ progress-tree = ["prodash/progress-tree"]
304304
## Print debugging information about usage of object database caches, useful for tuning cache sizes.
305305
cache-efficiency-debug = ["gix-features/cache-efficiency-debug"]
306306

307+
## Control gix-pack caching behavior
308+
## Provide a fixed-size allocation-free LRU cache for packs. It's useful if caching is desired while keeping the memory footprint
309+
## for the LRU-cache itself low.
310+
gix-pack-pack-cache-lru-static = ["gix-pack/pack-cache-lru-static"]
311+
312+
## Control gix-pack caching behavior
313+
## Provide a hash-map based LRU cache whose eviction is based a memory cap calculated from object data.
314+
gix-pack-pack-cache-lru-dynamic = ["gix-pack/pack-cache-lru-dynamic"]
315+
316+
## Control gix-pack caching behavior
317+
## If set, select algorithms may additionally use a full-object cache which is queried before the pack itself.
318+
gix-pack-object-cache-dynamic = ["gix-pack/object-cache-dynamic"]
307319

308320
[dependencies]
309321
gix-utils = { version = "^0.3.0", path = "../gix-utils" }
@@ -325,9 +337,7 @@ gix-hash = { version = "^0.19.0", path = "../gix-hash" }
325337
gix-shallow = { version = "^0.5.0", path = "../gix-shallow" }
326338
gix-object = { version = "^0.50.2", path = "../gix-object" }
327339
gix-actor = { version = "^0.35.4", path = "../gix-actor" }
328-
gix-pack = { version = "^0.60.0", path = "../gix-pack", default-features = false, features = [
329-
"object-cache-dynamic",
330-
] }
340+
gix-pack = { version = "^0.60.0", path = "../gix-pack", default-features = false }
331341
gix-revision = { version = "^0.35.0", path = "../gix-revision", default-features = false }
332342
gix-revwalk = { version = "^0.21.0", path = "../gix-revwalk" }
333343
gix-negotiate = { version = "^0.21.0", path = "../gix-negotiate", optional = true }

gix/src/object/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ pub use gix_object::Kind;
66
use crate::{Blob, Commit, Id, Object, ObjectDetached, Tag, Tree};
77

88
mod errors;
9+
#[cfg(feature = "object-cache-dynamic")]
910
pub(crate) mod cache {
1011
pub use gix_pack::cache::object::MemoryCappedHashmap;
1112
}

gix/src/repository/cache.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,12 @@ impl crate::Repository {
1212
let bytes = bytes.into();
1313
match bytes {
1414
Some(0) => self.objects.unset_object_cache(),
15-
Some(bytes) => self
16-
.objects
17-
.set_object_cache(move || Box::new(crate::object::cache::MemoryCappedHashmap::new(bytes))),
15+
Some(bytes) => {
16+
#[cfg(feature = "object-cache-dynamic")]
17+
self
18+
.objects
19+
.set_object_cache(move || Box::new(crate::object::cache::MemoryCappedHashmap::new(bytes)));
20+
},
1821
None => self.objects.unset_object_cache(),
1922
}
2023
}

gix/src/repository/init.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ pub(crate) fn setup_objects(objects: &mut crate::OdbHandle, config: &crate::conf
5656
objects.unset_object_cache();
5757
} else {
5858
let bytes = config.object_cache_bytes;
59+
#[cfg(feature = "object-cache-dynamic")]
5960
objects.set_object_cache(move || Box::new(gix_pack::cache::object::MemoryCappedHashmap::new(bytes)));
6061
}
6162
}

0 commit comments

Comments
 (0)