forked from NixOS/nix
-
Notifications
You must be signed in to change notification settings - Fork 18
Tarball cache performance improvements #627
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
c53f7d7
libfetchers: Support building against libgit2 2.0 (release candidate)
xokdvium 8899a4c
libfetchers: Disable GIT_OPT_ENABLE_STRICT_HASH_VERIFICATION
xokdvium 7c92a1f
libfetchers: Don't try to find deltas when unpacking to the tarball c…
xokdvium a257437
libfetchers: fix libgit2 pack window/bigfilethreshold config
xokdvium 9d2b155
packaging/secure-packages/flake.lock: Update
edolstra a73c8bb
packaging: Fix libgit2 eval error with provenance-enabled nixpkgs
edolstra File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| diff --git a/include/git2/sys/config.h b/include/git2/sys/config.h | ||
| index dcce18e6f..8945a3285 100644 | ||
| --- a/include/git2/sys/config.h | ||
| +++ b/include/git2/sys/config.h | ||
| @@ -200,7 +200,7 @@ GIT_EXTERN(int) git_config_backend_memory_options_init( | ||
| * @param opts the options to initialize this backend with, or NULL | ||
| * @return 0 on success or an error code | ||
| */ | ||
| -extern int git_config_backend_from_string( | ||
| +GIT_EXTERN(int) git_config_backend_from_string( | ||
| git_config_backend **out, | ||
| const char *cfg, | ||
| size_t len, | ||
| @@ -216,7 +216,7 @@ extern int git_config_backend_from_string( | ||
| * @param opts the options to initialize this backend with, or NULL | ||
| * @return 0 on success or an error code | ||
| */ | ||
| -extern int git_config_backend_from_values( | ||
| +GIT_EXTERN(int) git_config_backend_from_values( | ||
| git_config_backend **out, | ||
| const char **values, | ||
| size_t len, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| diff --git a/src/libgit2/pack-objects.c b/src/libgit2/pack-objects.c | ||
| index 0da84b657..d540795f9 100644 | ||
| --- a/src/libgit2/pack-objects.c | ||
| +++ b/src/libgit2/pack-objects.c | ||
| @@ -115,8 +115,9 @@ static int packbuilder_config(git_packbuilder *pb) | ||
| GIT_PACK_DELTA_CACHE_SIZE); | ||
| config_get("pack.deltaCacheLimit", pb->cache_max_small_delta_size, | ||
| GIT_PACK_DELTA_CACHE_LIMIT); | ||
| - config_get("pack.deltaCacheSize", pb->big_file_threshold, | ||
| + config_get("core.bigFileThreshold", pb->big_file_threshold, | ||
| GIT_PACK_BIG_FILE_THRESHOLD); | ||
| + config_get("pack.window", pb->window_size, GIT_PACK_WINDOW); | ||
| config_get("pack.windowMemory", pb->window_memory_limit, 0); | ||
|
|
||
| #undef config_get | ||
| @@ -1341,7 +1342,7 @@ int git_packbuilder__prepare(git_packbuilder *pb) | ||
| size_t i, n = 0; | ||
| int error; | ||
|
|
||
| - if (pb->nr_objects == 0 || pb->done) | ||
| + if (pb->nr_objects == 0 || pb->done || pb->window_size == 0) | ||
| return 0; /* nothing to do */ | ||
|
|
||
| /* | ||
| @@ -1369,7 +1370,7 @@ int git_packbuilder__prepare(git_packbuilder *pb) | ||
| if (n > 1) { | ||
| git__tsort((void **)delta_list, n, type_size_sort); | ||
| if ((error = ll_find_deltas(pb, delta_list, n, | ||
| - GIT_PACK_WINDOW + 1, | ||
| + pb->window_size + 1, | ||
| GIT_PACK_DEPTH)) < 0) { | ||
| git__free(delta_list); | ||
| return error; | ||
| diff --git a/src/libgit2/pack-objects.h b/src/libgit2/pack-objects.h | ||
| index ad04fb0ab..d9e03df60 100644 | ||
| --- a/src/libgit2/pack-objects.h | ||
| +++ b/src/libgit2/pack-objects.h | ||
| @@ -94,6 +94,7 @@ struct git_packbuilder { | ||
| size_t cache_max_small_delta_size; | ||
| size_t big_file_threshold; | ||
| size_t window_memory_limit; | ||
| + size_t window_size; | ||
|
|
||
| unsigned int nr_threads; /* nr of threads to use */ | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🌐 Web query:
libgit2 git_packbuilder__prepare pack-objects.c source pb->done delta_list💡 Result:
In the libgit2 codebase, the function git_packbuilderprepare (located in src/pack-objects.c) is responsible for preparing the packfile, which includes the deltafication stage [1][2]. The variables mentioned in your query—pb->done and delta_list—play specific roles within this preparation process: 1. pb->done: This is a boolean flag within the git_packbuilder structure [1]. When git_packbuilderprepare is invoked, it checks if pb->done is true; if it is, the function returns immediately because the preparation (deltafication) has already been completed [1][2]. Once the deltafication logic finishes successfully, the function sets pb->done to true to prevent redundant processing [1][2]. 2. delta_list: This is a temporary array of pointers to git_pobject structures (git_pobject delta_list) [1][2]. The function allocates this array based on the number of objects (pb->nr_objects) [1]. It then iterates through all objects in the packbuilder to identify candidates for deltafication—typically filtering by size constraints—and populates delta_list with these objects [1]. If there are objects to process (n > 1), it sorts the list using gittsort and proceeds to compute deltas using an internal function (often ll_find_deltas) [1][2]. After the delta computation is complete, the memory allocated for delta_list is freed [1][2]. This internal function is triggered by macros such as PREPARE_PACK whenever public APIs like git_packbuilder_write or git_packbuilder_foreach are called, ensuring that the necessary deltafication steps have occurred before the packfile is written [1][2].
Citations:
🤖 get_repo_knowledge executed:
get_repo_knowledge DeterminateSystems/nix-src /tmp/coderabbit-repo-knowledge/determinatesystems-nix-src-c05c47dfLength of output: 1105
🏁 Script executed:
Repository: DeterminateSystems/nix-src
Length of output: 2322
🏁 Script executed:
Repository: DeterminateSystems/nix-src
Length of output: 2149
🌐 Web query:
site:github.com/libgit2/libgit2 src/pack-objects.c git_packbuilder__prepare window_size pb->done write_pack💡 Result:
The identifiers and symbols you referenced relate to the internal implementation of the packbuilder module in libgit2, specifically within the src/pack-objects.c file [1][2]. git_packbuilderprepare: This is an internal function used by the libgit2 packbuilder to prepare the packfile before it is finalized or transmitted [3][1]. It performs necessary setup and orchestration—such as initializing packing logic—required before the actual writing of the pack contents occurs [3]. Historical context indicates this function was previously named prepare_pack before being renamed to its current internal-style name [1]. write_pack: This is a function (often found within src/pack-objects.c) responsible for the low-level logic of writing packfile data [2]. It is a critical component in the process of generating a valid packfile and is called during operations like git_packbuilder_write or when handling thin packs [4][5][6]. Related Concepts: - window_size: Typically refers to the delta compression window size used during the packing process. When libgit2 packs objects, it manages memory and compression strategies (often involving windows) to optimize the packing of object deltas [7][8]. - pb->done: This typically refers to an internal flag or state member within the packbuilder structure (pb) used to track whether a specific phase (or the entire packing operation) has been completed, aiding in state management during complex operations like network pushes [3]. In practice, users interact with these through the public API (such as git_packbuilder_write or git_packbuilder_foreach) rather than calling these internal functions directly [4][5]. These internal components work together to ensure objects are correctly sorted, delta-compressed, and serialized into the final packfile format [4][7].
Citations:
🏁 Script executed:
Repository: DeterminateSystems/nix-src
Length of output: 10215
🏁 Script executed:
Repository: DeterminateSystems/nix-src
Length of output: 6194
Keep preparation state and progress reporting when
window_size == 0. The early return skips theGIT_PACKBUILDER_DELTAFICATIONcallback, the finalreport_delta_progresscall, andpb->done = true.write_packcan still serialize the objects, butPREPARE_PACKruns twice ingit_packbuilder_write, so preparation remains unmarked and the progress stage is not reported. Skip onlyll_find_deltasfor a zero window, then run the existing progress and completion logic.🤖 Prompt for AI Agents