-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sync 'ds/multi-pack-index' to v2.19.0-rc0
* ds/multi-pack-index: (23 commits) midx: clear midx on repack packfile: skip loading index if in multi-pack-index midx: prevent duplicate packfile loads midx: use midx in approximate_object_count midx: use existing midx when writing new one midx: use midx in abbreviation calculations midx: read objects from multi-pack-index config: create core.multiPackIndex setting midx: write object offsets midx: write object id fanout chunk midx: write object ids in a chunk midx: sort and deduplicate objects from packfiles midx: read pack names into array multi-pack-index: write pack names in chunk multi-pack-index: read packfile list packfile: generalize pack directory list t5319: expand test data multi-pack-index: load into memory midx: write header information to lockfile multi-pack-index: add 'write' verb ...
- Loading branch information
Showing
21 changed files
with
1,720 additions
and
43 deletions.
There are no files selected for viewing
This file contains 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 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 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,56 @@ | ||
git-multi-pack-index(1) | ||
======================= | ||
|
||
NAME | ||
---- | ||
git-multi-pack-index - Write and verify multi-pack-indexes | ||
|
||
|
||
SYNOPSIS | ||
-------- | ||
[verse] | ||
'git multi-pack-index' [--object-dir=<dir>] <verb> | ||
|
||
DESCRIPTION | ||
----------- | ||
Write or verify a multi-pack-index (MIDX) file. | ||
|
||
OPTIONS | ||
------- | ||
|
||
--object-dir=<dir>:: | ||
Use given directory for the location of Git objects. We check | ||
`<dir>/packs/multi-pack-index` for the current MIDX file, and | ||
`<dir>/packs` for the pack-files to index. | ||
|
||
write:: | ||
When given as the verb, write a new MIDX file to | ||
`<dir>/packs/multi-pack-index`. | ||
|
||
|
||
EXAMPLES | ||
-------- | ||
|
||
* Write a MIDX file for the packfiles in the current .git folder. | ||
+ | ||
----------------------------------------------- | ||
$ git multi-pack-index write | ||
----------------------------------------------- | ||
|
||
* Write a MIDX file for the packfiles in an alternate object store. | ||
+ | ||
----------------------------------------------- | ||
$ git multi-pack-index --object-dir <alt> write | ||
----------------------------------------------- | ||
|
||
|
||
SEE ALSO | ||
-------- | ||
See link:technical/multi-pack-index.html[The Multi-Pack-Index Design | ||
Document] and link:technical/pack-format.html[The Multi-Pack-Index | ||
Format] for more information on the multi-pack-index feature. | ||
|
||
|
||
GIT | ||
--- | ||
Part of the linkgit:git[1] suite |
This file contains 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,109 @@ | ||
Multi-Pack-Index (MIDX) Design Notes | ||
==================================== | ||
|
||
The Git object directory contains a 'pack' directory containing | ||
packfiles (with suffix ".pack") and pack-indexes (with suffix | ||
".idx"). The pack-indexes provide a way to lookup objects and | ||
navigate to their offset within the pack, but these must come | ||
in pairs with the packfiles. This pairing depends on the file | ||
names, as the pack-index differs only in suffix with its pack- | ||
file. While the pack-indexes provide fast lookup per packfile, | ||
this performance degrades as the number of packfiles increases, | ||
because abbreviations need to inspect every packfile and we are | ||
more likely to have a miss on our most-recently-used packfile. | ||
For some large repositories, repacking into a single packfile | ||
is not feasible due to storage space or excessive repack times. | ||
|
||
The multi-pack-index (MIDX for short) stores a list of objects | ||
and their offsets into multiple packfiles. It contains: | ||
|
||
- A list of packfile names. | ||
- A sorted list of object IDs. | ||
- A list of metadata for the ith object ID including: | ||
- A value j referring to the jth packfile. | ||
- An offset within the jth packfile for the object. | ||
- If large offsets are required, we use another list of large | ||
offsets similar to version 2 pack-indexes. | ||
|
||
Thus, we can provide O(log N) lookup time for any number | ||
of packfiles. | ||
|
||
Design Details | ||
-------------- | ||
|
||
- The MIDX is stored in a file named 'multi-pack-index' in the | ||
.git/objects/pack directory. This could be stored in the pack | ||
directory of an alternate. It refers only to packfiles in that | ||
same directory. | ||
|
||
- The pack.multiIndex config setting must be on to consume MIDX files. | ||
|
||
- The file format includes parameters for the object ID hash | ||
function, so a future change of hash algorithm does not require | ||
a change in format. | ||
|
||
- The MIDX keeps only one record per object ID. If an object appears | ||
in multiple packfiles, then the MIDX selects the copy in the most- | ||
recently modified packfile. | ||
|
||
- If there exist packfiles in the pack directory not registered in | ||
the MIDX, then those packfiles are loaded into the `packed_git` | ||
list and `packed_git_mru` cache. | ||
|
||
- The pack-indexes (.idx files) remain in the pack directory so we | ||
can delete the MIDX file, set core.midx to false, or downgrade | ||
without any loss of information. | ||
|
||
- The MIDX file format uses a chunk-based approach (similar to the | ||
commit-graph file) that allows optional data to be added. | ||
|
||
Future Work | ||
----------- | ||
|
||
- Add a 'verify' subcommand to the 'git midx' builtin to verify the | ||
contents of the multi-pack-index file match the offsets listed in | ||
the corresponding pack-indexes. | ||
|
||
- The multi-pack-index allows many packfiles, especially in a context | ||
where repacking is expensive (such as a very large repo), or | ||
unexpected maintenance time is unacceptable (such as a high-demand | ||
build machine). However, the multi-pack-index needs to be rewritten | ||
in full every time. We can extend the format to be incremental, so | ||
writes are fast. By storing a small "tip" multi-pack-index that | ||
points to large "base" MIDX files, we can keep writes fast while | ||
still reducing the number of binary searches required for object | ||
lookups. | ||
|
||
- The reachability bitmap is currently paired directly with a single | ||
packfile, using the pack-order as the object order to hopefully | ||
compress the bitmaps well using run-length encoding. This could be | ||
extended to pair a reachability bitmap with a multi-pack-index. If | ||
the multi-pack-index is extended to store a "stable object order" | ||
(a function Order(hash) = integer that is constant for a given hash, | ||
even as the multi-pack-index is updated) then a reachability bitmap | ||
could point to a multi-pack-index and be updated independently. | ||
|
||
- Packfiles can be marked as "special" using empty files that share | ||
the initial name but replace ".pack" with ".keep" or ".promisor". | ||
We can add an optional chunk of data to the multi-pack-index that | ||
records flags of information about the packfiles. This allows new | ||
states, such as 'repacked' or 'redeltified', that can help with | ||
pack maintenance in a multi-pack environment. It may also be | ||
helpful to organize packfiles by object type (commit, tree, blob, | ||
etc.) and use this metadata to help that maintenance. | ||
|
||
- The partial clone feature records special "promisor" packs that | ||
may point to objects that are not stored locally, but available | ||
on request to a server. The multi-pack-index does not currently | ||
track these promisor packs. | ||
|
||
Related Links | ||
------------- | ||
[0] https://bugs.chromium.org/p/git/issues/detail?id=6 | ||
Chromium work item for: Multi-Pack Index (MIDX) | ||
|
||
[1] https://public-inbox.org/git/[email protected]/ | ||
An earlier RFC for the multi-pack-index feature | ||
|
||
[2] https://public-inbox.org/git/alpine.DEB.2.20.1803091557510.23109@alexmv-linux/ | ||
Git Merge 2018 Contributor's summit notes (includes discussion of MIDX) |
This file contains 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 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 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 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,47 @@ | ||
#include "builtin.h" | ||
#include "cache.h" | ||
#include "config.h" | ||
#include "parse-options.h" | ||
#include "midx.h" | ||
|
||
static char const * const builtin_multi_pack_index_usage[] = { | ||
N_("git multi-pack-index [--object-dir=<dir>] write"), | ||
NULL | ||
}; | ||
|
||
static struct opts_multi_pack_index { | ||
const char *object_dir; | ||
} opts; | ||
|
||
int cmd_multi_pack_index(int argc, const char **argv, | ||
const char *prefix) | ||
{ | ||
static struct option builtin_multi_pack_index_options[] = { | ||
OPT_FILENAME(0, "object-dir", &opts.object_dir, | ||
N_("object directory containing set of packfile and pack-index pairs")), | ||
OPT_END(), | ||
}; | ||
|
||
git_config(git_default_config, NULL); | ||
|
||
argc = parse_options(argc, argv, prefix, | ||
builtin_multi_pack_index_options, | ||
builtin_multi_pack_index_usage, 0); | ||
|
||
if (!opts.object_dir) | ||
opts.object_dir = get_object_directory(); | ||
|
||
if (argc == 0) | ||
goto usage; | ||
|
||
if (!strcmp(argv[0], "write")) { | ||
if (argc > 1) | ||
goto usage; | ||
|
||
return write_midx_file(opts.object_dir); | ||
} | ||
|
||
usage: | ||
usage_with_options(builtin_multi_pack_index_usage, | ||
builtin_multi_pack_index_options); | ||
} |
This file contains 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 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 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.