@@ -40,32 +40,32 @@ Values 1-4 satisfy the requirements of parse_commit_gently().
40
40
41
41
Define the "generation number" of a commit recursively as follows:
42
42
43
- * A commit with no parents (a root commit) has generation number one.
43
+ * A commit with no parents (a root commit) has generation number one.
44
44
45
- * A commit with at least one parent has generation number one more than
46
- the largest generation number among its parents.
45
+ * A commit with at least one parent has generation number one more than
46
+ the largest generation number among its parents.
47
47
48
48
Equivalently, the generation number of a commit A is one more than the
49
49
length of a longest path from A to a root commit. The recursive definition
50
50
is easier to use for computation and observing the following property:
51
51
52
- If A and B are commits with generation numbers N and M, respectively,
53
- and N <= M, then A cannot reach B. That is, we know without searching
54
- that B is not an ancestor of A because it is further from a root commit
55
- than A.
52
+ If A and B are commits with generation numbers N and M, respectively,
53
+ and N <= M, then A cannot reach B. That is, we know without searching
54
+ that B is not an ancestor of A because it is further from a root commit
55
+ than A.
56
56
57
- Conversely, when checking if A is an ancestor of B, then we only need
58
- to walk commits until all commits on the walk boundary have generation
59
- number at most N. If we walk commits using a priority queue seeded by
60
- generation numbers, then we always expand the boundary commit with highest
61
- generation number and can easily detect the stopping condition.
57
+ Conversely, when checking if A is an ancestor of B, then we only need
58
+ to walk commits until all commits on the walk boundary have generation
59
+ number at most N. If we walk commits using a priority queue seeded by
60
+ generation numbers, then we always expand the boundary commit with highest
61
+ generation number and can easily detect the stopping condition.
62
62
63
63
This property can be used to significantly reduce the time it takes to
64
64
walk commits and determine topological relationships. Without generation
65
65
numbers, the general heuristic is the following:
66
66
67
- If A and B are commits with commit time X and Y, respectively, and
68
- X < Y, then A _probably_ cannot reach B.
67
+ If A and B are commits with commit time X and Y, respectively, and
68
+ X < Y, then A _probably_ cannot reach B.
69
69
70
70
This heuristic is currently used whenever the computation is allowed to
71
71
violate topological relationships due to clock skew (such as "git log"
@@ -85,8 +85,11 @@ have generation number represented by the macro GENERATION_NUMBER_ZERO = 0.
85
85
Since the commit-graph file is closed under reachability, we can guarantee
86
86
the following weaker condition on all commits:
87
87
88
- If A and B are commits with generation numbers N amd M, respectively,
89
- and N < M, then A cannot reach B.
88
+ [quote]
89
+ _____________________________________________________________________
90
+ If A and B are commits with generation numbers N amd M, respectively,
91
+ and N < M, then A cannot reach B.
92
+ _____________________________________________________________________
90
93
91
94
Note how the strict inequality differs from the inequality when we have
92
95
fully-computed generation numbers. Using strict inequality may result in
@@ -121,11 +124,8 @@ Future Work
121
124
- After computing and storing generation numbers, we must make graph
122
125
walks aware of generation numbers to gain the performance benefits they
123
126
enable. This will mostly be accomplished by swapping a commit-date-ordered
124
- priority queue with one ordered by generation number. The following
125
- operations are important candidates:
126
-
127
- - 'log --topo-order'
128
- - 'tag --merged'
127
+ priority queue with one ordered by generation number. Commands that could
128
+ improve include 'git log --topo-order' and 'git tag --merged'.
129
129
130
130
- A server could provide a commit graph file as part of the network protocol
131
131
to avoid extra calculations by clients. This feature is only of benefit if
@@ -148,13 +148,16 @@ Related Links
148
148
More discussion about generation numbers and not storing them inside
149
149
commit objects. A valuable quote:
150
150
151
- "I think we should be moving more in the direction of keeping
152
- repo-local caches for optimizations. Reachability bitmaps have been
153
- a big performance win. I think we should be doing the same with our
154
- properties of commits. Not just generation numbers, but making it
155
- cheap to access the graph structure without zlib-inflating whole
156
- commit objects (i.e., packv4 or something like the "metapacks" I
157
- proposed a few years ago)."
151
+ [quote, Jeff "Peff" King]
152
+ ____________________________________________________________________
153
+ I think we should be moving more in the direction of keeping
154
+ repo-local caches for optimizations. Reachability bitmaps have been
155
+ a big performance win. I think we should be doing the same with our
156
+ properties of commits. Not just generation numbers, but making it
157
+ cheap to access the graph structure without zlib-inflating whole
158
+ commit objects (i.e., packv4 or something like the "metapacks" I
159
+ proposed a few years ago).
160
+ ____________________________________________________________________
158
161
159
162
[4] https://public-inbox.org/git/
[email protected] /T/#u
160
163
A patch to remove the ahead-behind calculation from 'status'.
0 commit comments