Skip to content

Commit 8847676

Browse files
committed
feat: add max-control feature for fine-grained performance control.
This also adds the following performance features: - `zlib-ng` - `zlib-ng-compat` - `zlib-stock` - `parallel-walkdir`
1 parent db86fba commit 8847676

File tree

1 file changed

+31
-13
lines changed

1 file changed

+31
-13
lines changed

gix/Cargo.toml

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -141,15 +141,29 @@ blocking-http-transport-reqwest-native-tls = ["blocking-http-transport-reqwest",
141141
#! The reason these features exist is to allow optimization for compile time and optimize for compatibility by default. This means that some performance options around
142142
#! SHA1 and ZIP might not compile on all platforms, so it depends on the end-user who compiles the application to chose these based on their needs.
143143

144-
## 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
145-
## on some platforms.
146-
max-performance-safe = [
144+
## Activate features that maximize performance, like using threads, but leave everything else that might affect compatibility out to allow users more fine-grained
145+
## control over performance features like which `zlib*` implementation to use.
146+
## No C toolchain is involved.
147+
max-control = [
147148
"parallel",
148149
"pack-cache-lru-static",
149150
"pack-cache-lru-dynamic",
150-
"gix-features/fs-walkdir-parallel"
151151
]
152152

153+
## Activate features that maximize performance, like usage of threads, `and access to caching in object databases, skipping the ones known to cause compile failures
154+
## on some platforms.
155+
## Note that this configuration still uses a pure Rust zlib implementation which isn't the fastest compared to its C-alternatives.
156+
## No C toolchain is involved.
157+
max-performance-safe = [
158+
"max-control",
159+
"parallel-walkdir"
160+
]
161+
162+
## If set, walkdir iterators will be multi-threaded which affects the listing of loose objects and references.
163+
## Note, however, that this will use `rayon` under the hood and spawn threads for each traversal to avoid a global rayon thread pool.
164+
## Thus this option is more interesting to one-off client applications, rather than the server.
165+
parallel-walkdir = ["gix-features/fs-walkdir-parallel"]
166+
153167
## The tempfile registry uses a better implementation of a thread-safe hashmap, relying on an external crate.
154168
## This may be useful when tempfiles are created and accessed in a massively parallel fashion and you know that this is indeed faster than
155169
## the simpler implementation that is the default.
@@ -169,20 +183,24 @@ pack-cache-lru-dynamic = ["gix-pack/pack-cache-lru-dynamic"]
169183

170184
## Activate other features that maximize performance, like usage of threads, `zlib-ng` and access to caching in object databases.
171185
## Note that some platforms might suffer from compile failures, which is when `max-performance-safe` should be used.
172-
max-performance = [ "max-performance-safe", "gix-features/zlib-ng", "fast-sha1" ]
173-
174-
## Activate other features that maximize performance, like usage of threads, `zlib-ng-compat`, and access to caching in object databases.
175-
## Note that some platforms might suffer from compile failures, which is when `max-performance-safe` should be used.
176-
## Unlike `max-performance`, `max-performance-zlib-ng-compat` uses zlib-ng via
177-
## libz-sys in zlib-ng-compat mode, which is useful when building with other
178-
## software that needs zlib, or to avoid linking conflicts when using other
179-
## software that uses zlib-ng-compat.
180-
max-performance-zlib-ng-compat = [ "max-performance-safe", "gix-features/zlib-ng-compat", "fast-sha1" ]
186+
max-performance = [ "max-performance-safe", "zlib-ng", "fast-sha1" ]
181187

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

192+
## Use the C-based zlib-ng backend, which can compress and decompress significantly faster.
193+
## Note that this will cause duplicate symbol errors if the application also depends on `zlib` - use `zlib-ng-compat` in that case.
194+
zlib-ng = ["gix-features/zlib-ng"]
195+
196+
## Use zlib-ng via its zlib-compat API. Useful if you already need zlib for C
197+
## code elsewhere in your dependencies. Otherwise, use `zlib-ng`.
198+
zlib-ng-compat = ["gix-features/zlib-ng-compat"]
199+
200+
## Use a slower C-based backend which can compress and decompress significantly faster than the rust version.
201+
## Unlike `zlib-ng-compat`, this allows using dynamic linking with system `zlib` libraries and doesn't require cmake.
202+
zlib-stock = ["gix-features/zlib-stock"]
203+
186204
#! #### Other
187205
#!
188206
#! The catch-all of feature toggles.

0 commit comments

Comments
 (0)