mirror of
https://github.com/git/git.git
synced 2026-10-03 20:57:21 +02:00
Before diffing a target blob against a parent, offer the pair's identity to the hunk provider interface. Blame's requests have gone through diff_provider_emit_hunks() since the interface arrived, but carried no identity, so nothing could answer them. Now blame fills in the pair's blob object ids and its diff options, and the chain serves the pair from the store, keyed by the ids and the request's xdiff flags, before the terminal provider falls back to fill-and-compute. Blame diffs at zero context, which is not part of the key. An answer replays the recorded hunks through blame_chunk_cb without loading either blob; a request carrying -I patterns or anchors is outside the key and always computes. Blame withholds the identity where its diff is not the plain blob-pair diff the key describes: reverse blame, ignored revisions, textconv paths, and the working-tree or --contents pseudo-commit, whose blob is not a stored object. Those requests always compute. Whitespace and algorithm options such as -w instead change blame's xdl_opts, so the consult keys a different entry and misses a store warmed without them. Blame's default xdl_opts now come from DIFF_HUNKS_DEFAULT_XDL_OPTS, new here, which records the key-relevant defaults a diff_options-based consumer already carries (today the indent heuristic), so a default blame run and a default "log --stat" warming run share keys by construction. "--show-stats" reports how many pairs the store served and how many consultations it could not, read from diff_hunks_read_stats(); the store counts its own consultations, so blame keeps no tally. Extend t4220 with the blame side: - parity for plain, --porcelain, and --incremental output, and hit and miss accounting across warming runs; - the blame inputs that must bypass or miss the store: -w, indent heuristics, --reverse, textconv, -M/-C, and the --ignore-rev pass; - rename and merge handling, and --contents; - reading a truncated or corrupt store as absent, and a crafted zero-hunk record as a miss that verify flags. Add p4218, measuring the cost of a warming run and the read speedups. Signed-off-by: Michael Montalbo <mmontalbo@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
49 lines
1.0 KiB
Bash
Executable File
49 lines
1.0 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
test_description='diff-hunks store performance'
|
|
. ./perf-lib.sh
|
|
|
|
test_perf_default_repo
|
|
|
|
# Pick a file to blame pseudo-randomly. The sort key is the blob
|
|
# hash, so it is stable.
|
|
test_expect_success 'select a file' '
|
|
git ls-tree -r HEAD | grep ^100644 |
|
|
sort -k 3 | head -n 1 | cut -f 2 >filelist
|
|
'
|
|
|
|
file=$(cat filelist)
|
|
export file
|
|
|
|
# Warm the store the way an owner would: a stat walk with writing on.
|
|
test_perf 'warm the store' '
|
|
git diff-hunks clear &&
|
|
GIT_DIFF_HUNKS_WRITE=1 git log --all --stat >/dev/null
|
|
'
|
|
|
|
test_expect_success 'ensure the store is warm for the timed reads' '
|
|
GIT_DIFF_HUNKS_WRITE=1 git log --all --stat >/dev/null
|
|
'
|
|
|
|
test_perf 'log --stat -1000 (store)' '
|
|
git log --stat -1000 >/dev/null
|
|
'
|
|
|
|
test_perf 'log --stat -1000 (no store)' '
|
|
git -c core.diffhunks=false log --stat -1000 >/dev/null
|
|
'
|
|
|
|
test_perf 'blame $file (store)' '
|
|
git blame "$file" >/dev/null
|
|
'
|
|
|
|
test_perf 'blame $file (no store)' '
|
|
git -c core.diffhunks=false blame "$file" >/dev/null
|
|
'
|
|
|
|
test_expect_success 'clean up store' '
|
|
git diff-hunks clear
|
|
'
|
|
|
|
test_done
|