git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 3/3] p2000: add performance test for 'git add -p'

From
Derrick Stolee via GitGitGadget <gitgitgadget@gmail.com>
Date
May 7, 2025, 00:55 UTC
Message-ID
<7a777281626dc5fa9b191efe25442e0e856950e6.1746579321.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.1914.git.1746579320.gitgitgadget@gmail.com>
From: Derrick Stolee <stolee@gmail.com>

The previous two changes contributed performance improvements to 'git apply' and 'git add -p' when using a sparse index. Add a performance test to demonstrate this (and to help validate that performance remains good in the future).

In the truncated test output below, we see that the full checkout performance changes within noise expectations, but the sparse index cases improve 33% and then 96%.

                      HEAD~3     HEAD~2         HEAD~1
---------------------------------------------------------
2000.118: (full-v3)     0.80   0.84 +5.0%     0.84  +5.0%
2000.119: (full-v4)     0.76   0.79 +3.9%     0.80  +5.3%
2000.120: (sparse-v3)   2.09   1.39 -33.5%    0.07 -96.7%
2000.121: (sparse-v4)   2.09   1.39 -33.5%    0.07 -96.7%

It is worth noting that if our test was more involved and had multiple hunks to evaluate, then the time spent in 'git apply' would dominate due to multiple index loads and writes. As it stands, we need the sparse index improvement in 'git add -p' itself to confirm this performance improvement.

Since the change for 'git add -i' is identical, we avoid a second test case for that similar operation.

Signed-off-by: Derrick Stolee <stolee@gmail.com>
---
 t/perf/p2000-sparse-operations.sh | 1 +
 1 file changed, 1 insertion(+)
diff --git a/t/perf/p2000-sparse-operations.sh b/t/perf/p2000-sparse-operations.sh
index 39e92b084143..3da6ae59c000 100755
--- a/t/perf/p2000-sparse-operations.sh
+++ b/t/perf/p2000-sparse-operations.sh
@@ -135,5 +135,6 @@ test_perf_on_all git diff-tree HEAD
 test_perf_on_all git diff-tree HEAD -- $SPARSE_CONE/a
 test_perf_on_all "git worktree add ../temp && git worktree remove ../temp"
 test_perf_on_all git check-attr -a -- $SPARSE_CONE/a
+test_perf_on_all 'echo >>a && test_write_lines y | git add -p'
 
 test_done
-- 
gitgitgadget
Previous: Derrick StoleeNext: Elijah Newren
Message 8 of 22 in “Integrate the sparse index with 'git apply' and 'git add -p/-i'”
  1. 0/3 Integrate the sparse index with 'git apply' and 'git add -p/-i'Derrick Stolee via GitGitGadget, May 7, 2025
  2. 1/3 apply: integrate with the sparse indexDerrick Stolee via GitGitGadget, May 7, 2025
  3. Elijah NewrenMay 10, 2025
  4. Derrick StoleeMay 16, 2025
  5. 2/3 git add: make -p/-i aware of sparse indexDerrick Stolee via GitGitGadget, May 7, 2025
  6. Elijah NewrenMay 10, 2025
  7. Derrick StoleeMay 16, 2025
  8. 3/3 p2000: add performance test for 'git add -p'Derrick Stolee via GitGitGadget, May 7, 2025
  9. Elijah NewrenMay 10, 2025
  10. Junio C HamanoMay 8, 2025
  11. Phillip WoodMay 14, 2025
  12. Derrick StoleeMay 16, 2025
  13. phillip.wood123@gmail.comMay 20, 2025
  14. 0/4 Integrate the sparse index with 'git apply' and interactive add, checkout, and resetDerrick Stolee via GitGitGadget, May 16, 2025
  15. 1/4 apply: integrate with the sparse indexDerrick Stolee via GitGitGadget, May 16, 2025
  16. 2/4 git add: make -p/-i aware of sparse indexDerrick Stolee via GitGitGadget, May 16, 2025
  17. 3/4 reset: integrate sparse index with --patchDerrick Stolee via GitGitGadget, May 16, 2025
  18. Elijah NewrenMay 16, 2025
  19. 4/4 p2000: add performance test for patch-mode commandsDerrick Stolee via GitGitGadget, May 16, 2025
  20. Elijah NewrenMay 16, 2025
  21. Derrick StoleeMay 16, 2025
  22. Junio C HamanoMay 16, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.