Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions gix/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ required-features = ["blocking-network-client"]

[features]

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

#! There are various categories of features which help to optimize performance and build times. `gix` comes with 'batteries included' and everything is
#! 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
Expand Down Expand Up @@ -304,6 +304,18 @@ progress-tree = ["prodash/progress-tree"]
## Print debugging information about usage of object database caches, useful for tuning cache sizes.
cache-efficiency-debug = ["gix-features/cache-efficiency-debug"]

## Control gix-pack caching behavior
## Provide a fixed-size allocation-free LRU cache for packs. It's useful if caching is desired while keeping the memory footprint
## for the LRU-cache itself low.
gix-pack-pack-cache-lru-static = ["gix-pack/pack-cache-lru-static"]

## Control gix-pack caching behavior
## Provide a hash-map based LRU cache whose eviction is based a memory cap calculated from object data.
gix-pack-pack-cache-lru-dynamic = ["gix-pack/pack-cache-lru-dynamic"]

## Control gix-pack caching behavior
## If set, select algorithms may additionally use a full-object cache which is queried before the pack itself.
gix-pack-object-cache-dynamic = ["gix-pack/object-cache-dynamic"]

[dependencies]
gix-utils = { version = "^0.3.0", path = "../gix-utils" }
Expand All @@ -325,9 +337,7 @@ gix-hash = { version = "^0.19.0", path = "../gix-hash" }
gix-shallow = { version = "^0.5.0", path = "../gix-shallow" }
gix-object = { version = "^0.50.2", path = "../gix-object" }
gix-actor = { version = "^0.35.4", path = "../gix-actor" }
gix-pack = { version = "^0.60.0", path = "../gix-pack", default-features = false, features = [
"object-cache-dynamic",
] }
gix-pack = { version = "^0.60.0", path = "../gix-pack", default-features = false }
gix-revision = { version = "^0.35.0", path = "../gix-revision", default-features = false }
gix-revwalk = { version = "^0.21.0", path = "../gix-revwalk" }
gix-negotiate = { version = "^0.21.0", path = "../gix-negotiate", optional = true }
Expand Down
1 change: 1 addition & 0 deletions gix/src/object/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ pub use gix_object::Kind;
use crate::{Blob, Commit, Id, Object, ObjectDetached, Tag, Tree};

mod errors;
#[cfg(feature = "object-cache-dynamic")]
pub(crate) mod cache {
pub use gix_pack::cache::object::MemoryCappedHashmap;
}
Expand Down
9 changes: 6 additions & 3 deletions gix/src/repository/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@ impl crate::Repository {
let bytes = bytes.into();
match bytes {
Some(0) => self.objects.unset_object_cache(),
Some(bytes) => self
.objects
.set_object_cache(move || Box::new(crate::object::cache::MemoryCappedHashmap::new(bytes))),
Some(bytes) => {
#[cfg(feature = "object-cache-dynamic")]
self
.objects
.set_object_cache(move || Box::new(crate::object::cache::MemoryCappedHashmap::new(bytes)));
},
None => self.objects.unset_object_cache(),
}
}
Expand Down
1 change: 1 addition & 0 deletions gix/src/repository/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ pub(crate) fn setup_objects(objects: &mut crate::OdbHandle, config: &crate::conf
objects.unset_object_cache();
} else {
let bytes = config.object_cache_bytes;
#[cfg(feature = "object-cache-dynamic")]
objects.set_object_cache(move || Box::new(gix_pack::cache::object::MemoryCappedHashmap::new(bytes)));
}
}
Expand Down
Loading