1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-28 09:16:10 +02:00
git/builtin
Derrick Stolee 0906ac2b54 blame: use changed-path Bloom filters
The changed-path Bloom filters help reduce the amount of tree
parsing required during history queries. Before calculating a
diff, we can ask the filter if a path changed between a commit
and its first parent. If the filter says "no" then we can move
on without parsing trees. If the filter says "maybe" then we
parse trees to discover if the answer is actually "yes" or "no".

When computing a blame, there is a section in find_origin() that
computes a diff between a commit and one of its parents. When this
is the first parent, we can check the Bloom filters before calling
diff_tree_oid().

In order to make this work with the blame machinery, we need to
initialize a struct bloom_key with the initial path. But also, we
need to add more keys to a list if a rename is detected. We then
check to see if _any_ of these keys answer "maybe" in the diff.

During development, I purposefully left out this "add a new key
when a rename is detected" to see if the test suite would catch
my error. That is how I discovered the issues with
GIT_TEST_COMMIT_GRAPH_CHANGED_PATHS from the previous change.
With that change, we can feel some confidence in the coverage of
this change.

If a user requests copy detection using "git blame -C", then there
are more places where the set of "important" files can expand. I
do not know enough about how this happens in the blame machinery.
Thus, the Bloom filter integration is explicitly disabled in this
mode. A later change could expand the bloom_key data with an
appropriate call (or calls) to add_bloom_key().

If we did not disable this mode, then the following tests would
fail:

	t8003-blame-corner-cases.sh
	t8011-blame-split-file.sh

Generally, this is a performance enhancement and should not
change the behavior of 'git blame' in any way. If a repo has a
commit-graph file with computed changed-path Bloom filters, then
they should notice improved performance for their 'git blame'
commands.

Here are some example timings that I found by blaming some paths
in the Linux kernel repository:

 git blame arch/x86/kernel/topology.c >/dev/null

 Before: 0.83s
  After: 0.24s

 git blame kernel/time/time.c >/dev/null

 Before: 0.72s
  After: 0.24s

 git blame tools/perf/ui/stdio/hist.c >/dev/null

 Before: 0.27s
  After: 0.11s

I specifically looked for "deep" paths that were also edited many
times. As a counterpoint, the MAINTAINERS file was edited many
times but is located in the root tree. This means that the cost of
computing a diff relative to the pathspec is very small. Here are
the timings for that command:

 git blame MAINTAINERS >/dev/null

 Before: 20.1s
  After: 18.0s

These timings are the best of five. The worst-case runs were on the
order of 2.5 minutes for both cases. Note that the MAINTAINERS file
has 18,740 lines across 17,000+ commits. This happens to be one of
the cases where this change provides the least improvement.

The lack of improvement for the MAINTAINERS file and the relatively
modest improvement for the other examples can be easily explained.
The blame machinery needs to compute line-level diffs to determine
which lines were changed by each commit. That makes up a large
proportion of the computation time, and this change does not
attempt to improve on that section of the algorithm. The
MAINTAINERS file is large and changed often, so it takes time to
determine which lines were updated by which commit. In contrast,
the code files are much smaller, and it takes longer to comute
the line-by-line diff for a single patch on the Linux mailing
lists.

Outside of the "-C" integration, I believe there is little more to
gain from the changed-path Bloom filters for 'git blame' after this
patch.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-04-16 15:38:06 -07:00
..
add.c Merge branch 'hw/advice-add-nothing' 2020-02-14 12:54:19 -08:00
am.c am: support --show-current-patch=diff to retrieve .git/rebase-apply/patch 2020-02-20 13:20:41 -08:00
annotate.c
apply.c
archive.c pack-protocol.txt: accept error packets in any context 2019-01-02 13:05:30 -08:00
bisect--helper.c bisect: libify `check_good_are_ancestors_of_bad` and its dependents 2020-02-19 09:37:14 -08:00
blame.c blame: use changed-path Bloom filters 2020-04-16 15:38:06 -07:00
branch.c l10n: minor case fix in 'git branch' '--unset-upstream' description 2019-12-09 12:30:55 -08:00
bundle.c bundle-verify: add --quiet 2019-11-11 11:46:29 +09:00
cat-file.c convert: provide additional metadata to filters 2020-03-16 11:37:02 -07:00
check-attr.c cache.h: flip NO_THE_INDEX_COMPATIBILITY_MACROS switch 2019-01-24 11:55:06 -08:00
check-ignore.c check-ignore: fix documentation and implementation to match 2020-02-18 15:28:58 -08:00
check-mailmap.c
check-ref-format.c
checkout-index.c Merge branch 'nd/the-index-final' 2019-02-06 22:05:23 -08:00
checkout.c builtin/checkout: compute checkout metadata for checkouts 2020-03-16 11:37:02 -07:00
clean.c Merge branch 'en/clean-nested-with-ignored' 2019-10-11 14:24:46 +09:00
clone.c Merge branch 'bc/filter-process' 2020-03-26 17:11:20 -07:00
column.c builtin: consistently pass cmd_* prefix to parse_options 2019-05-13 14:22:53 +09:00
commit-graph.c commit-graph: add GIT_TEST_COMMIT_GRAPH_CHANGED_PATHS test flag 2020-04-06 11:08:37 -07:00
commit-tree.c commit-tree: utilize parse-options api 2019-03-08 10:31:24 +09:00
commit.c tests: write commit-graph with Bloom filters 2020-04-16 15:38:04 -07:00
config.c config: add '--show-scope' to print the scope of a config value 2020-02-10 10:49:12 -08:00
count-objects.c rename "alternate_object_database" to "object_directory" 2018-11-13 14:22:02 +09:00
credential.c
describe.c Merge branch 'jc/describe-misnamed-annotated-tag' 2020-03-26 17:11:21 -07:00
diff-files.c cache.h: flip NO_THE_INDEX_COMPATIBILITY_MACROS switch 2019-01-24 11:55:06 -08:00
diff-index.c cache.h: flip NO_THE_INDEX_COMPATIBILITY_MACROS switch 2019-01-24 11:55:06 -08:00
diff-tree.c Merge branch 'en/combined-all-paths' 2019-03-07 09:59:54 +09:00
diff.c Merge branch 'nd/diff-parseopt-4' 2019-04-25 16:41:12 +09:00
difftool.c hashmap: remove type arg from hashmap_{get,put,remove}_entry 2019-10-07 10:20:12 +09:00
env--helper.c env--helper: mark a file-local symbol as static 2019-07-11 14:31:04 -07:00
fast-export.c Merge branch 'mt/use-passed-repo-more-in-funcs' 2020-02-14 12:54:22 -08:00
fetch-pack.c fetch_pack(): drop unused parameters 2019-03-20 18:34:09 +09:00
fetch.c Merge branch 'ds/partial-clone-fixes' 2020-03-02 15:07:19 -08:00
fmt-merge-msg.c gpg-interface: prefer check_signature() for GPG verification 2020-03-15 09:46:28 -07:00
for-each-ref.c parse_opt_ref_sorting: always use with NONEG flag 2019-03-21 12:03:35 +09:00
fsck.c fsck: only provide oid/type in fsck_error callback 2019-10-28 14:05:18 +09:00
gc.c commit-graph.h: store an odb in 'struct write_commit_graph_context' 2020-02-04 11:36:37 -08:00
get-tar-commit-id.c builtin/get-tar-commit-id: make hash size independent 2019-04-01 11:57:39 +09:00
grep.c Merge branch 'mt/threaded-grep-in-object-store' 2020-02-14 12:54:20 -08:00
hash-object.c builtin: consistently pass cmd_* prefix to parse_options 2019-05-13 14:22:53 +09:00
help.c completion: add more parameter value completion 2019-02-20 12:31:56 -08:00
index-pack.c Merge branch 'jk/index-pack-dupfix' 2020-02-14 12:54:24 -08:00
init-db.c Merge branch 'bc/sha-256-part-1-of-4' 2020-03-26 17:11:20 -07:00
interpret-trailers.c interpret-trailers: load default config 2019-06-19 07:12:49 -07:00
log.c Merge branch 'dl/format-patch-notes-config-fixup' 2019-12-25 11:21:58 -08:00
ls-files.c Merge branch 'ds/include-exclude' 2019-09-30 13:19:32 +09:00
ls-remote.c parse_opt_ref_sorting: always use with NONEG flag 2019-03-21 12:03:35 +09:00
ls-tree.c Merge branch 'nd/attr-pathspec-in-tree-walk' 2019-01-14 15:29:28 -08:00
mailinfo.c
mailsplit.c
merge-base.c rebase: --fork-point regression fix 2020-02-11 09:59:39 -08:00
merge-file.c assert NOARG/NONEG behavior of parse-options callbacks 2018-11-06 12:56:29 +09:00
merge-index.c cache.h: flip NO_THE_INDEX_COMPATIBILITY_MACROS switch 2019-01-24 11:55:06 -08:00
merge-ours.c cache.h: flip NO_THE_INDEX_COMPATIBILITY_MACROS switch 2019-01-24 11:55:06 -08:00
merge-recursive.c Ensure index matches head before invoking merge machinery, round N 2019-08-19 10:08:03 -07:00
merge-tree.c Merge branch 'jk/tree-walk-overflow' 2019-08-22 12:34:10 -07:00
merge.c tests: write commit-graph with Bloom filters 2020-04-16 15:38:04 -07:00
mktag.c sha1-file: allow check_object_signature() to handle any repo 2020-01-31 10:45:39 -08:00
mktree.c mktree: drop unused length parameter 2019-05-13 14:22:54 +09:00
multi-pack-index.c multi-pack-index: add [--[no-]progress] option. 2019-10-23 12:05:06 +09:00
mv.c cache.h: flip NO_THE_INDEX_COMPATIBILITY_MACROS switch 2019-01-24 11:55:06 -08:00
name-rev.c name-rev: sort tip names before applying 2020-02-05 10:36:33 -08:00
notes.c strbuf: add and use strbuf_insertstr() 2020-02-10 09:04:45 -08:00
pack-objects.c Merge branch 'ds/default-pack-use-sparse-to-true' 2020-03-29 09:32:51 -07:00
pack-redundant.c object-store: rename and expand packed_git's sha1 member 2019-04-01 11:57:38 +09:00
pack-refs.c Honor core.precomposeUnicode in more places 2019-04-26 10:54:03 +09:00
patch-id.c patch-id: use oid_to_hex() to print multiple object IDs 2019-12-09 12:26:40 -08:00
prune-packed.c Merge branch 'rj/prune-packed-excess-args' 2019-03-07 09:59:55 +09:00
prune.c object: convert lookup_object() to use object_id 2019-06-20 10:18:09 -07:00
pull.c pull: warn if the user didn't say whether to rebase or to merge 2020-03-10 13:06:41 -07:00
push.c push: use skip_prefix() instead of starts_with() 2019-11-27 11:18:39 +09:00
range-diff.c range-diff: clear `other_arg` at end of function 2019-12-06 12:36:53 -08:00
read-tree.c sparse-checkout: update working directory in-process 2019-11-22 16:11:44 +09:00
rebase.c Merge branch 'bc/filter-process' 2020-03-26 17:11:20 -07:00
receive-pack.c receive.denyCurrentBranch: respect all worktrees 2020-02-24 11:14:43 -08:00
reflog.c C: use skip_prefix() to avoid hardcoded string length 2020-01-31 13:03:45 -08:00
remote-ext.c
remote-fd.c
remote.c remote rename/remove: gently handle remote.pushDefault config 2020-02-10 10:52:10 -08:00
repack.c Merge branch 'wb/midx-progress' 2019-11-10 18:02:14 +09:00
replace.c sha1-file: pass git_hash_algo to hash_object_file() 2020-01-31 10:45:39 -08:00
rerere.c Merge branch 'nd/the-index' into md/list-objects-filter-by-depth 2019-01-15 15:38:29 -08:00
reset.c builtin/reset: compute checkout metadata for reset 2020-03-16 11:37:02 -07:00
rev-list.c rev-list --count: comment on the use of count_right++ 2020-02-18 13:21:46 -08:00
rev-parse.c get_superproject_working_tree(): return strbuf 2020-03-10 11:41:40 -07:00
revert.c Merge branch 'ra/cherry-pick-revert-skip' 2019-07-19 11:30:21 -07:00
rm.c rm: support the --pathspec-from-file option 2020-02-19 10:56:49 -08:00
send-pack.c pack-protocol.txt: accept error packets in any context 2019-01-02 13:05:30 -08:00
shortlog.c Merge branch 'nd/show-gitcomp-compilation-fix' into maint 2018-12-15 12:24:33 +09:00
show-branch.c use strpbrk(3) to search for characters from a given set 2020-02-24 09:30:31 -08:00
show-index.c builtin/show-index: replace sha1_to_hex 2019-08-19 15:04:59 -07:00
show-ref.c Merge branch 'en/unicode-in-refnames' 2019-05-19 16:45:30 +09:00
sparse-checkout.c Merge branch 'ds/sparse-add' 2020-03-05 10:43:02 -08:00
stash.c Merge branch 'tg/retire-scripted-stash' 2020-03-26 17:11:21 -07:00
stripspace.c stripspace: allow -s/-c outside git repository 2018-12-26 15:41:47 -08:00
submodule--helper.c submodule--helper.c: Rename 'cb_foreach' to 'foreach_cb' 2020-03-18 12:43:25 -07:00
symbolic-ref.c
tag.c tag: use new advice API to check visibility 2020-03-05 06:15:04 -08:00
unpack-file.c
unpack-objects.c sha1-file: pass git_hash_algo to hash_object_file() 2020-01-31 10:45:39 -08:00
update-index.c Merge branch 'js/update-index-ignore-removal-for-skip-worktree' 2019-11-10 18:02:16 +09:00
update-ref.c
update-server-info.c
upload-archive.c
upload-pack.c builtin: consistently pass cmd_* prefix to parse_options 2019-05-13 14:22:53 +09:00
var.c
verify-commit.c Merge branch 'jk/no-system-includes-in-dot-c' 2019-07-31 14:38:56 -07:00
verify-pack.c
verify-tag.c verify-tag: drop signal.h include 2019-06-19 08:19:21 -07:00
worktree.c real_path: remove unsafe API 2020-03-10 11:41:40 -07:00
write-tree.c cmd_{read,write}_tree: rename "unused" variable that is used 2019-05-13 14:22:53 +09:00