<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/t/perf, branch v2.40.2</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=v2.40.2</id>
<link rel='self' href='https://git.shady.money/git/atom?h=v2.40.2'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2023-01-18T23:24:52Z</updated>
<entry>
<title>grep: correctly identify utf-8 characters with \{b,w} in -P</title>
<updated>2023-01-18T23:24:52Z</updated>
<author>
<name>Carlo Marcelo Arenas Belón</name>
<email>carenas@gmail.com</email>
</author>
<published>2023-01-08T15:52:17Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=acabd2048ee0ee53728100408970ab45a6dab65e'/>
<id>urn:sha1:acabd2048ee0ee53728100408970ab45a6dab65e</id>
<content type='text'>
When UTF is enabled for a PCRE match, the corresponding flags are
added to the pcre2_compile() call, but PCRE2_UCP wasn't included.

This prevents extending the meaning of the character classes to
include those new valid characters and therefore result in failed
matches for expressions that rely on that extention, for ex:

  $ git grep -P '\bÆvar'

Add PCRE2_UCP so that \w will include Æ and therefore \b could
correctly match the beginning of that word.

This has an impact on performance that has been estimated to be
between 20% to 40% and that is shown through the added performance
test.

Signed-off-by: Carlo Marcelo Arenas Belón &lt;carenas@gmail.com&gt;
Acked-by: Ævar Arnfjörð Bjarmason &lt;avarab@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>read-tree: use 'skip_cache_tree_update' option</title>
<updated>2022-11-11T02:49:34Z</updated>
<author>
<name>Victoria Dye</name>
<email>vdye@github.com</email>
</author>
<published>2022-11-10T19:06:04Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=dc5d40f5bc4d93dcc57ee82c5ca8d1369055d8cb'/>
<id>urn:sha1:dc5d40f5bc4d93dcc57ee82c5ca8d1369055d8cb</id>
<content type='text'>
When running 'read-tree' with a single tree and no prefix,
'prime_cache_tree()' is called after the tree is unpacked. In that
situation, skip a redundant call to 'cache_tree_update()' in
'unpack_trees()' by enabling the 'skip_cache_tree_update' unpack option.

Removing the redundant cache tree update provides a substantial performance
improvement to 'git read-tree &lt;tree-ish&gt;', as shown by a test added to
'p0006-read-tree-checkout.sh':

Test                          before            after
----------------------------------------------------------------------
read-tree br_ballast_plus_1   3.94(1.80+1.57)   3.00(1.14+1.28) -23.9%

Note that the 'read-tree' in 't1022-read-tree-partial-clone.sh' is updated
to read two trees, rather than one. The test was first introduced in
d3da223f221 (cache-tree: prefetch in partial clone read-tree, 2021-07-23) to
exercise the 'cache_tree_update()' code path, as used in 'git merge'. Since
this patch drops the call to 'cache_tree_update()' in single-tree 'git
read-tree', change the test to use the two-tree variant so that
'cache_tree_update()' is called as intended.

Signed-off-by: Victoria Dye &lt;vdye@github.com&gt;
Signed-off-by: Taylor Blau &lt;me@ttaylorr.com&gt;
</content>
</entry>
<entry>
<title>reset: use 'skip_cache_tree_update' option</title>
<updated>2022-11-11T02:49:34Z</updated>
<author>
<name>Victoria Dye</name>
<email>vdye@github.com</email>
</author>
<published>2022-11-10T19:06:03Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=0e47bca0f7592f8053ffcc530d8afa1d2e364563'/>
<id>urn:sha1:0e47bca0f7592f8053ffcc530d8afa1d2e364563</id>
<content type='text'>
Enable the 'skip_cache_tree_update' option in the variants that call
'prime_cache_tree()' after 'unpack_trees()' (specifically, 'git reset
--mixed' and 'git reset --hard'). This avoids redundantly rebuilding the
cache tree in both 'cache_tree_update()' at the end of 'unpack_trees()' and
in 'prime_cache_tree()', resulting in a small (but consistent) performance
improvement. From the newly-added 'p7102-reset.sh' test:

Test                         before            after
--------------------------------------------------------------------
7102.1: reset --hard (...)   2.11(0.40+1.54)   1.97(0.38+1.47) -6.6%

Signed-off-by: Victoria Dye &lt;vdye@github.com&gt;
Signed-off-by: Taylor Blau &lt;me@ttaylorr.com&gt;
</content>
</entry>
<entry>
<title>cache-tree: add perf test comparing update and prime</title>
<updated>2022-11-11T02:49:33Z</updated>
<author>
<name>Victoria Dye</name>
<email>vdye@github.com</email>
</author>
<published>2022-11-10T19:06:01Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=94fcf0e85207979e3a7b35ad348cdd6b7ab42058'/>
<id>urn:sha1:94fcf0e85207979e3a7b35ad348cdd6b7ab42058</id>
<content type='text'>
Add a performance test comparing the execution times of 'prime_cache_tree()'
and 'cache_tree_update(_, WRITE_TREE_SILENT | WRITE_TREE_REPAIR)'. The goal
of comparing these two is to identify which is the faster method for
rebuilding an invalid cache tree, ultimately to remove one when both are
(reundantly) called in immediate succession.

Both methods are fast, so the new tests in 'p0090-cache-tree.sh' must call
each tested function multiple times to ensure the reported times (to 0.01s
resolution) convey the differences between them.

The tests compare the timing of a 'test-tool cache-tree' run as a no-op (to
capture a baseline for the overhead associated with running the tool),
'cache_tree_update()', and 'prime_cache_tree()' on four scenarios:

- A completely valid cache tree
- A cache tree with 2 invalid paths
- A cache tree with 50 invalid paths
- A completely empty cache tree

Example results:

Test                                        this tree
-----------------------------------------------------------
0090.2: no-op, clean                        1.27(0.48+0.52)
0090.3: prime_cache_tree, clean             2.02(0.83+0.85)
0090.4: cache_tree_update, clean            1.30(0.49+0.54)
0090.5: no-op, invalidate 2                 1.29(0.48+0.54)
0090.6: prime_cache_tree, invalidate 2      1.98(0.81+0.83)
0090.7: cache_tree_update, invalidate 2     2.12(0.94+0.86)
0090.8: no-op, invalidate 50                1.32(0.50+0.55)
0090.9: prime_cache_tree, invalidate 50     2.10(0.86+0.89)
0090.10: cache_tree_update, invalidate 50   2.35(1.14+0.90)
0090.11: no-op, empty                       1.33(0.50+0.54)
0090.12: prime_cache_tree, empty            2.04(0.84+0.87)
0090.13: cache_tree_update, empty           2.51(1.27+0.92)

These timings show that, while 'cache_tree_update()' is faster when the
cache tree is completely valid, it is equal to or slower than
'prime_cache_tree()' when there are any invalid paths. Since the redundant
calls are mostly in scenarios where the cache tree will be at least
partially invalid (e.g., 'git reset --hard'), 'prime_cache_tree()' will
likely perform better than 'cache_tree_update()' in typical cases.

Helped-by: SZEDER Gábor &lt;szeder.dev@gmail.com&gt;
Signed-off-by: Victoria Dye &lt;vdye@github.com&gt;
Signed-off-by: Taylor Blau &lt;me@ttaylorr.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'sy/sparse-grep'</title>
<updated>2022-10-10T17:08:40Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2022-10-10T17:08:40Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=67bf4a83e9fcd18a2135215d4fd18e84f742d09b'/>
<id>urn:sha1:67bf4a83e9fcd18a2135215d4fd18e84f742d09b</id>
<content type='text'>
"git grep" learned to expand the sparse-index more lazily and on
demand in a sparse checkout.

* sy/sparse-grep:
  builtin/grep.c: integrate with sparse index
</content>
</entry>
<entry>
<title>builtin/grep.c: integrate with sparse index</title>
<updated>2022-09-23T16:41:27Z</updated>
<author>
<name>Shaoxuan Yuan</name>
<email>shaoxuan.yuan02@gmail.com</email>
</author>
<published>2022-09-23T04:18:42Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=7cae7627c459ae5d0cd8f4c1ff76601e6c952bf3'/>
<id>urn:sha1:7cae7627c459ae5d0cd8f4c1ff76601e6c952bf3</id>
<content type='text'>
Turn on sparse index and remove ensure_full_index().

Before this patch, `git-grep` utilizes the ensure_full_index() method to
expand the index and search all the entries. Because this method
requires walking all the trees and constructing the index, it is the
slow part within the whole command.

To achieve better performance, this patch uses grep_tree() to search the
sparse directory entries and get rid of the ensure_full_index() method.

Why grep_tree() is a better choice over ensure_full_index()?

1) grep_tree() is as correct as ensure_full_index(). grep_tree() looks
   into every sparse-directory entry (represented by a tree) recursively
   when looping over the index, and the result of doing so matches the
   result of expanding the index.

2) grep_tree() utilizes pathspecs to limit the scope of searching.
   ensure_full_index() always expands the index, which means it will
   always walk all the trees and blobs in the repo without caring if
   the user only wants a subset of the content, i.e. using a pathspec.
   On the other hand, grep_tree() will only search the contents that
   match the pathspec, and thus possibly walking fewer trees.

3) grep_tree() does not construct and copy back a new index, while
   ensure_full_index() does. This also saves some time.

----------------
Performance test

- Summary:

p2000 tests demonstrate a ~71% execution time reduction for
`git grep --cached bogus -- "f2/f1/f1/*"` using tree-walking logic.
However, notice that this result varies depending on the pathspec
given. See below "Command used for testing" for more details.

Test                              HEAD~   HEAD
-------------------------------------------------------
2000.78: git grep ... (full-v3)   0.35    0.39 (≈)
2000.79: git grep ... (full-v4)   0.36    0.30 (≈)
2000.80: git grep ... (sparse-v3) 0.88    0.23 (-73.8%)
2000.81: git grep ... (sparse-v4) 0.83    0.26 (-68.6%)

- Command used for testing:

	git grep --cached bogus -- "f2/f1/f1/*"

The reason for specifying a pathspec is that, if we don't specify a
pathspec, then grep_tree() will walk all the trees and blobs to find the
pattern, and the time consumed doing so is not too different from using
the original ensure_full_index() method, which also spends most of the
time walking trees. However, when a pathspec is specified, this latest
logic will only walk the area of trees enclosed by the pathspec, and the
time consumed is reasonably a lot less.

Generally speaking, because the performance gain is acheived by walking
less trees, which are specified by the pathspec, the HEAD time v.s.
HEAD~ time in sparse-v[3|4], should be proportional to
"pathspec enclosed area" v.s. "all area", respectively. Namely, the
wider the &lt;pathspec&gt; is encompassing, the less the performance
difference between HEAD~ and HEAD, and vice versa.

That is, if we don't specify a pathspec, the performance difference [1]
is indistinguishable: both methods walk all the trees and take generally
same amount of time (even with the index construction time included for
ensure_full_index()).

[1] Performance test result without pathspec (hence walking all trees):

	Command used:

		git grep --cached bogus

	Test                                HEAD~  HEAD
	---------------------------------------------------
	2000.78: git grep ... (full-v3)     6.17   5.19 (≈)
	2000.79: git grep ... (full-v4)     6.19   5.46 (≈)
	2000.80: git grep ... (sparse-v3)   6.57   6.44 (≈)
	2000.81: git grep ... (sparse-v4)   6.65   6.28 (≈)

--------------------------
NEEDSWORK about submodules

There are a few NEEDSWORKs that belong to improvements beyond this
topic. See the NEEDSWORK in builtin/grep.c::grep_submodule() for
more context. The other two NEEDSWORKs in t1092 are also relative.

Suggested-by: Derrick Stolee &lt;derrickstolee@github.com&gt;
Helped-by: Derrick Stolee &lt;derrickstolee@github.com&gt;
Helped-by: Victoria Dye &lt;vdye@github.com&gt;
Helped-by: Elijah Newren &lt;newren@gmail.com&gt;
Signed-off-by: Shaoxuan Yuan &lt;shaoxuan.yuan02@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>t: convert egrep usage to "grep -E"</title>
<updated>2022-09-21T18:00:18Z</updated>
<author>
<name>Đoàn Trần Công Danh</name>
<email>congdanhqx@gmail.com</email>
</author>
<published>2022-09-21T13:02:31Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=81580fa06d85ef519a46b0b225cebfe71c168a37'/>
<id>urn:sha1:81580fa06d85ef519a46b0b225cebfe71c168a37</id>
<content type='text'>
Despite POSIX states that:

&gt; The old egrep and fgrep commands are likely to be supported for many
&gt; years to come as implementation extensions, allowing historical
&gt; applications to operate unmodified.

GNU grep 3.8 started to warn[1]:

&gt; The egrep and fgrep commands, which have been deprecated since
&gt; release 2.5.3 (2007), now warn that they are obsolescent and should
&gt; be replaced by grep -E and grep -F.

Prepare for their removal in the future.

[1]: https://lists.gnu.org/archive/html/info-gnu/2022-09/msg00001.html

Signed-off-by: Đoàn Trần Công Danh &lt;congdanhqx@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'vd/scalar-to-main'</title>
<updated>2022-09-19T21:35:25Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2022-09-19T21:35:25Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=42bf77c7d013ac595b3463eb064b66d7b969f55c'/>
<id>urn:sha1:42bf77c7d013ac595b3463eb064b66d7b969f55c</id>
<content type='text'>
Hoist the remainder of "scalar" out of contrib/ to the main part of
the codebase.

* vd/scalar-to-main:
  Documentation/technical: include Scalar technical doc
  t/perf: add 'GIT_PERF_USE_SCALAR' run option
  t/perf: add Scalar performance tests
  scalar-clone: add test coverage
  scalar: add to 'git help -a' command list
  scalar: implement the `help` subcommand
  git help: special-case `scalar`
  scalar: include in standard Git build &amp; installation
  scalar: fix command documentation section header
</content>
</entry>
<entry>
<title>Merge branch 'ac/bitmap-lookup-table'</title>
<updated>2022-09-06T01:33:39Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2022-09-06T01:33:39Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=3fe0121479ea340936d11927efa5a45a4e1e39cc'/>
<id>urn:sha1:3fe0121479ea340936d11927efa5a45a4e1e39cc</id>
<content type='text'>
The pack bitmap file gained a bitmap-lookup table to speed up
locating the necessary bitmap for a given commit.

* ac/bitmap-lookup-table:
  pack-bitmap-write: drop unused pack_idx_entry parameters
  bitmap-lookup-table: add performance tests for lookup table
  pack-bitmap: prepare to read lookup table extension
  pack-bitmap-write: learn pack.writeBitmapLookupTable and add tests
  pack-bitmap-write.c: write lookup table extension
  bitmap: move `get commit positions` code to `bitmap_writer_finish`
  Documentation/technical: describe bitmap lookup table extension
</content>
</entry>
<entry>
<title>t/perf: add 'GIT_PERF_USE_SCALAR' run option</title>
<updated>2022-09-02T17:02:56Z</updated>
<author>
<name>Victoria Dye</name>
<email>vdye@github.com</email>
</author>
<published>2022-09-02T15:56:49Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=ba1b117eec2f73c84f73f827e6f3ac8b82b35585'/>
<id>urn:sha1:ba1b117eec2f73c84f73f827e6f3ac8b82b35585</id>
<content type='text'>
Add a 'GIT_PERF_USE_SCALAR' environment variable (and corresponding perf
config 'useScalar') to register a repository created with any of:

* test_perf_fresh_repo
* test_perf_default_repo
* test_perf_large_repo

as a Scalar enlistment. This is intended to allow a developer to test the
impact of Scalar on already-defined performance scenarios.

Suggested-by: Derrick Stolee &lt;derrickstolee@github.com&gt;
Signed-off-by: Victoria Dye &lt;vdye@github.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
