Skip to content

Commit

Permalink
feat: support avoiding usage of fast-sha1 in git-features separately.
Browse files Browse the repository at this point in the history
That way one has an angle on compile failures in client libraries,
see o2sh/onefetch#752 for motivation.
  • Loading branch information
Byron committed Aug 23, 2022
1 parent bd02b39 commit c28bcec
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 12 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ check: ## Build all code in suitable configurations
&& cargo check --no-default-features --features blocking-network-client,blocking-http-transport \
&& cargo check --no-default-features --features one-stop-shop \
&& cargo check --no-default-features --features max-performance \
&& cargo check --no-default-features --features max-performance-safe \
&& cargo check --no-default-features
cd git-odb && cargo check --features serde1
cd cargo-smart-release && cargo check --all
Expand Down
23 changes: 16 additions & 7 deletions git-repository/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,23 @@ serde1 = [ "serde",
"git-mailmap/serde1",
"git-attributes/serde1",
"git-revision/serde1"]
## Activate other features that maximize performance, like usage of threads, `zlib-ng` and access to caching in object databases.
## **Note** that

max-performance = [ "git-features/fast-sha1",
"git-features/parallel",
"git-features/zlib-ng-compat",
"git-pack/pack-cache-lru-static",
"git-pack/pack-cache-lru-dynamic"]
## Activate other features that maximize performance, like usage of threads, `zlib-ng` and access to caching in object databases.
## Note that some platforms might suffer from compile failures, which is when `max-performance-safe` should be used.
max-performance = [ "fast-sha1", "max-performance-safe" ]

## If enabled, use assembly versions of sha1 on supported platforms.
## This might cause compile failures as well which is why it can be turned off separately.
fast-sha1 = [ "git-features/fast-sha1" ]

## Activate features that maximize performance, like usage of threads, `zlib-ng` and access to caching in object databases, skipping the ones known to cause compile failures
## on some platforms.
max-performance-safe = [
"git-features/parallel",
"git-features/zlib-ng-compat",
"git-pack/pack-cache-lru-static",
"git-pack/pack-cache-lru-dynamic"
]
## Re-export stability tier 2 crates for convenience and make `Repository` struct fields with types from these crates publicly accessible.
## Doing so is less stable than the stability tier 1 that `git-repository` is a member of.
unstable = ["git-mailmap", "git-credentials"]
Expand Down
6 changes: 3 additions & 3 deletions git-repository/src/repository/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ impl crate::Repository {
/// Use the `GITOXIDE_OBJECT_CACHE_MEMORY=16mb` to set the given amount of memory to store full objects, on a per-thread basis.
pub fn apply_environment(self) -> Self {
// We have no cache types available without this flag currently. Maybe this should change at some point.
#[cfg(not(feature = "max-performance"))]
#[cfg(not(feature = "max-performance-safe"))]
return self;
#[cfg(feature = "max-performance")]
#[cfg(feature = "max-performance-safe")]
{
let pack_cache_disabled = std::env::var_os("GITOXIDE_DISABLE_PACK_CACHE").is_some();
let mut this = self;
Expand All @@ -69,7 +69,7 @@ impl crate::Repository {
}
}

#[cfg(feature = "max-performance")]
#[cfg(feature = "max-performance-safe")]
fn parse_bytes_from_var(name: &str) -> Option<usize> {
std::env::var(name)
.ok()
Expand Down
4 changes: 2 additions & 2 deletions git-repository/src/repository/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ impl crate::Repository {
work_tree,
common_dir,
objects: {
#[cfg(feature = "max-performance")]
#[cfg(feature = "max-performance-safe")]
{
objects.with_pack_cache(|| Box::new(git_pack::cache::lru::StaticLinkedList::<64>::default()))
}
#[cfg(not(feature = "max-performance"))]
#[cfg(not(feature = "max-performance-safe"))]
{
objects
}
Expand Down

0 comments on commit c28bcec

Please sign in to comment.