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