]> git.ipfire.org Git - thirdparty/git.git/commitdiff
pack-bitmap: remove trace2 region from hot path
authorDerrick Stolee <derrickstolee@github.com>
Mon, 26 Sep 2022 13:17:57 +0000 (13:17 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 26 Sep 2022 19:09:18 +0000 (12:09 -0700)
The trace2 region around the call to lazy_bitmap_for_commit() in
bitmap_for_commit() was added in 28cd730680d (pack-bitmap: prepare to
read lookup table extension, 2022-08-14). While adding trace2 regions is
typically helpful for tracking performance, this method is called
possibly thousands of times as a commit walk explores commit history
looking for a matching bitmap. When trace2 output is enabled, this
region is emitted many times and performance is throttled by that
output.

For now, remove these regions entirely.

This is a critical path, and it would be valuable to measure that the
time spent in bitmap_for_commit() does not increase when using the
commit lookup table. The best way to do that would be to use a mechanism
that sums the time spent in a region and reports a single value at the
end of the process. This technique was introduced but not merged by [1]
so maybe this example presents some justification to revisit that
approach.

[1] https://lore.kernel.org/git/pull.1099.v2.git.1640720202.gitgitgadget@gmail.com/

To help with the 'git blame' output in this region, add a comment that
warns against adding a trace2 region. Delete a test from t5310 that used
that trace output to check that this lookup optimization was activated.
To create this kind of test again in the future, the stopwatch traces
mentioned earlier could be used as a signal that we activated this code
path.

Helpedy-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Derrick Stolee <derrickstolee@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
pack-bitmap.c
t/t5310-pack-bitmaps.sh

index 9a208abc1fdd920926a1b8ee22e0a8bf5371743e..a2bbbbd811dbe845fdf02d60e008d97b9975bdb6 100644 (file)
@@ -830,10 +830,9 @@ struct ewah_bitmap *bitmap_for_commit(struct bitmap_index *bitmap_git,
                if (!bitmap_git->table_lookup)
                        return NULL;
 
-               trace2_region_enter("pack-bitmap", "reading_lookup_table", the_repository);
+               /* this is a fairly hot codepath - no trace2_region please */
                /* NEEDSWORK: cache misses aren't recorded */
                bitmap = lazy_bitmap_for_commit(bitmap_git, commit);
-               trace2_region_leave("pack-bitmap", "reading_lookup_table", the_repository);
                if (!bitmap)
                        return NULL;
                return lookup_stored_bitmap(bitmap);
index 7e50f8e7653f65128d965502b13d7aa3d61d4782..6d693eef82f74a72ad4f29c399e297427c892d12 100755 (executable)
@@ -455,13 +455,6 @@ test_expect_success 'verify writing bitmap lookup table when enabled' '
        grep "\"label\":\"writing_lookup_table\"" trace2
 '
 
-test_expect_success 'lookup table is actually used to traverse objects' '
-       git repack -adb &&
-       GIT_TRACE2_EVENT="$(pwd)/trace3" \
-               git rev-list --use-bitmap-index --count --all &&
-       grep "\"label\":\"reading_lookup_table\"" trace3
-'
-
 test_expect_success 'truncated bitmap fails gracefully (lookup table)' '
        test_config pack.writebitmaphashcache false &&
        git repack -adb &&