interplane.Get Omega
Read in your language

git

[Ported from github.com/git/git] Sync with Git 2.56.1

Brought by drakestapleton

branch master Branches Tags History

git / Documentation / gitpacking.adoc

191 lines · 7432 bytes Raw Blame History
1gitpacking(7)
2=============
3
4NAME
5----
6gitpacking - Advanced concepts related to packing in Git
7
8DESCRIPTION
9-----------
10
11This document aims to describe some advanced concepts related to packing
12in Git.
13
14Many concepts are currently described scattered between manual pages of
15various Git commands, including linkgit:git-pack-objects[1],
16linkgit:git-repack[1], and others, as well as linkgit:gitformat-pack[5],
17and parts of the `Documentation/technical` tree.
18
19There are many aspects of packing in Git that are not covered in this
20document that instead live in the aforementioned areas. Over time, those
21scattered bits may coalesce into this document.
22
23== Pseudo-merge bitmaps
24
25NOTE: Pseudo-merge bitmaps are considered an experimental feature, so
26the configuration and many of the ideas are subject to change.
27
28=== Background
29
30Reachability bitmaps are most efficient when we have on-disk stored
31bitmaps for one or more of the starting points of a traversal. For this
32reason, Git prefers storing bitmaps for commits at the tips of refs,
33because traversals tend to start with those points.
34
35But if you have a large number of refs, it's not feasible to store a
36bitmap for _every_ ref tip. It takes up space, and just OR-ing all of
37those bitmaps together is expensive.
38
39One way we can deal with that is to create bitmaps that represent
40_groups_ of refs. When a traversal asks about the entire group, then we
41can use this single bitmap instead of considering each ref individually.
42Because these bitmaps represent the set of objects which would be
43reachable in a hypothetical merge of all of the commits, we call them
44pseudo-merge bitmaps.
45
46=== Overview
47
48A "pseudo-merge bitmap" is used to refer to a pair of bitmaps, as
49follows:
50
51Commit bitmap::
52
53 A bitmap whose set bits describe the set of commits included in the
54 pseudo-merge's "merge" bitmap (as below).
55
56Merge bitmap::
57
58 A bitmap whose set bits describe the reachability closure over the set
59 of commits in the pseudo-merge's "commits" bitmap (as above). An
60 identical bitmap would be generated for an octopus merge with the same
61 set of parents as described in the commits bitmap.
62
63Pseudo-merge bitmaps can accelerate bitmap traversals when all commits
64for a given pseudo-merge are listed on either side of the traversal,
65either directly (by explicitly asking for them as part of the `HAVES`
66or `WANTS`) or indirectly (by encountering them during a fill-in
67traversal).
68
69=== Use-cases
70
71For example, suppose there exists a pseudo-merge bitmap with a large
72number of commits, all of which are listed in the `WANTS` section of
73some bitmap traversal query. When pseudo-merge bitmaps are enabled, the
74bitmap machinery can quickly determine there is a pseudo-merge which
75satisfies some subset of the wanted objects on either side of the query.
76Then, we can inflate the EWAH-compressed bitmap, and `OR` it in to the
77resulting bitmap. By contrast, without pseudo-merge bitmaps, we would
78have to repeat the decompression and `OR`-ing step over a potentially
79large number of individual bitmaps, which can take proportionally more
80time.
81
82Another benefit of pseudo-merges arises when there is some combination
83of (a) a large number of references, with (b) poor bitmap coverage, and
84(c) deep, nested trees, making fill-in traversal relatively expensive.
85For example, suppose that there are a large enough number of tags where
86bitmapping each of the tags individually is infeasible. Without
87pseudo-merge bitmaps, computing the result of, say, `git rev-list
88--use-bitmap-index --count --objects --tags` would likely require a
89large amount of fill-in traversal. But when a large quantity of those
90tags are stored together in a pseudo-merge bitmap, the bitmap machinery
91can take advantage of the fact that we only care about the union of
92objects reachable from all of those tags, and answer the query much
93faster.
94
95=== Configuration
96
97Reference tips are grouped into different pseudo-merge groups according
98to two criteria. A reference name matches one or more of the defined
99pseudo-merge patterns, and optionally one or more capture groups within
100that pattern which further partition the group.
101
102Within a group, commits may be considered "stable", or "unstable"
103depending on their age. These are adjusted by setting the
104`bitmapPseudoMerge.<name>.stableThreshold` and
105`bitmapPseudoMerge.<name>.threshold` configuration values, respectively.
106
107All stable commits are grouped into pseudo-merges of equal size
108(`bitmapPseudoMerge.<name>.stableSize`). If the `stableSize`
109configuration is set to, say, 100, then the first 100 commits (ordered
110by committer date) which are older than the `stableThreshold` value will
111form one group, the next 100 commits will form another group, and so on.
112
113Among unstable commits, the pseudo-merge machinery will attempt to
114combine older commits into large groups as opposed to newer commits
115which will appear in smaller groups. This is based on the heuristic that
116references whose tip commit is older are less likely to be modified to
117point at a different commit than a reference whose tip commit is newer.
118
119The size of groups is determined by a power-law decay function, and the
120decay parameter roughly corresponds to "k" in `f(n) = C*n^(-k/100)`,
121where `f(n)` describes the size of the `n`-th pseudo-merge group. The
122sample rate controls what percentage of eligible commits are considered
123as candidates. The threshold parameter indicates the minimum age (so as
124to avoid including too-recent commits in a pseudo-merge group, making it
125less likely to be valid). The "maxMerges" parameter sets an upper-bound
126on the number of pseudo-merge commits an individual group
127
128The "stable"-related parameters control "stable" pseudo-merge groups,
129comprised of a fixed number of commits which are older than the
130configured "stable threshold" value and may be grouped together in
131chunks of "stableSize" in order of age.
132
133The exact configuration for pseudo-merges is as follows:
134
135include::config/bitmap-pseudo-merge.adoc[]
136
137=== Examples
138
139Suppose that you have a repository with a large number of references,
140and you want a bare-bones configuration of pseudo-merge bitmaps that
141will enhance bitmap coverage of the `refs/` namespace. You may start
142with a configuration like so:
143
144----
145[bitmapPseudoMerge "all"]
146 pattern = "refs/"
147 threshold = now
148 stableThreshold = never
149 sampleRate = 1
150 maxMerges = 64
151----
152
153This will create pseudo-merge bitmaps for all references, regardless of
154their age, and group them into 64 pseudo-merge commits.
155
156If you wanted to separate tags from branches when generating
157pseudo-merge commits, you would instead define the pattern with a
158capture group, like so:
159
160----
161[bitmapPseudoMerge "all"]
162 pattern = "refs/(heads/tags)/"
163----
164
165Suppose instead that you are working in a fork-network repository, with
166each fork specified by some numeric ID, and whose refs reside in
167`refs/virtual/NNN/` (where `NNN` is the numeric ID corresponding to some
168fork) in the network. In this instance, you may instead write something
169like:
170
171----
172[bitmapPseudoMerge "all"]
173 pattern = "refs/virtual/([0-9]+)/(heads|tags)/"
174 threshold = now
175 stableThreshold = never
176 sampleRate = 1
177 maxMerges = 64
178----
179
180Which would generate pseudo-merge group identifiers like "1234-heads",
181and "5678-tags" (for branches in fork "1234", and tags in remote "5678",
182respectively).
183
184SEE ALSO
185--------
186linkgit:git-pack-objects[1]
187linkgit:git-repack[1]
188
189GIT
190---
191Part of the linkgit:git[1] suite