Commit d7c1ec3
commit: add short-circuit to paint_down_to_common()
When running 'git branch --contains', the in_merge_bases_many()
method calls paint_down_to_common() to discover if a specific
commit is reachable from a set of branches. Commits with lower
generation number are not needed to correctly answer the
containment query of in_merge_bases_many().
Add a new parameter, min_generation, to paint_down_to_common() that
prevents walking commits with generation number strictly less than
min_generation. If 0 is given, then there is no functional change.
For in_merge_bases_many(), we can pass commit->generation as the
cutoff, and this saves time during 'git branch --contains' queries
that would otherwise walk "around" the commit we are inspecting.
For a copy of the Linux repository, where HEAD is checked out at
v4.13~100, we get the following performance improvement for
'git branch --contains' over the previous commit:
Before: 0.21s
After: 0.13s
Rel %: -38%
Signed-off-by: Derrick Stolee <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>1 parent f9b8908 commit d7c1ec3
1 file changed
+16
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
808 | 808 | | |
809 | 809 | | |
810 | 810 | | |
811 | | - | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
812 | 814 | | |
813 | 815 | | |
814 | 816 | | |
815 | 817 | | |
| 818 | + | |
816 | 819 | | |
817 | 820 | | |
818 | 821 | | |
| |||
831 | 834 | | |
832 | 835 | | |
833 | 836 | | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
834 | 846 | | |
835 | 847 | | |
836 | 848 | | |
| |||
879 | 891 | | |
880 | 892 | | |
881 | 893 | | |
882 | | - | |
| 894 | + | |
883 | 895 | | |
884 | 896 | | |
885 | 897 | | |
| |||
946 | 958 | | |
947 | 959 | | |
948 | 960 | | |
949 | | - | |
| 961 | + | |
950 | 962 | | |
951 | 963 | | |
952 | 964 | | |
| |||
1070 | 1082 | | |
1071 | 1083 | | |
1072 | 1084 | | |
1073 | | - | |
| 1085 | + | |
1074 | 1086 | | |
1075 | 1087 | | |
1076 | 1088 | | |
| |||
0 commit comments