git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] pack-bitmap: remove trace2 region from hot path
@ 2022-09-23 13:00 Derrick Stolee via GitGitGadget
  2022-09-23 17:05 ` Junio C Hamano
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Derrick Stolee via GitGitGadget @ 2022-09-23 13:00 UTC (permalink / raw)
  To: git
  Cc: gitster, git, me, chakrabortyabhradeep79, Derrick Stolee,
	Derrick Stolee

From: Derrick Stolee <derrickstolee@github.com>

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/

Signed-off-by: Derrick Stolee <derrickstolee@github.com>
---
    [For 2.38.0] pack-bitmap: remove trace2 region from hot path
    
    I noticed this while trying to backport the Abhradeep's lookup table
    work into GitHub's fork. Something went wrong in that process, causing
    this region to significantly slow down. It turns out that slow down does
    not reproduce on current 'master', which is good. I must have missed
    something while I was backporting.
    
    Regardless, the use of trace2_region_enter() here should be removed or
    replaced. For the sake of 2.38.0, this simple removal is safe enough.
    However, to really dig into what was happening I had to construct a
    rebase [2] of Jeff's trace2 stopwatch work, then apply changes on top
    [3] that could replace this region with trace2_timer_*() methods.
    
    [2]
    https://github.com/git/git/compare/master...derrickstolee:trace2-stopwatch
    [3]
    https://github.com/derrickstolee/git/compare/trace2-stopwatch...bitmap-trace2
    
    As a separate discussion, it might be worth revisiting that stopwatch
    work so we have it available as a tool when doing these kinds of
    investigations.
    
    Thanks, -Stolee

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1365%2Fderrickstolee%2Fbitmap-remove-trace2-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1365/derrickstolee/bitmap-remove-trace2-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/1365

 pack-bitmap.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/pack-bitmap.c b/pack-bitmap.c
index 9a208abc1fd..13457dd77e5 100644
--- a/pack-bitmap.c
+++ b/pack-bitmap.c
@@ -830,10 +830,8 @@ 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);
 		/* 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);

base-commit: 1b3d6e17fe83eb6f79ffbac2f2c61bbf1eaef5f8
-- 
gitgitgadget

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH] pack-bitmap: remove trace2 region from hot path
  2022-09-23 13:00 [PATCH] pack-bitmap: remove trace2 region from hot path Derrick Stolee via GitGitGadget
@ 2022-09-23 17:05 ` Junio C Hamano
  2022-09-23 17:25   ` Junio C Hamano
  2022-09-23 17:36 ` Junio C Hamano
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 10+ messages in thread
From: Junio C Hamano @ 2022-09-23 17:05 UTC (permalink / raw)
  To: Derrick Stolee via GitGitGadget
  Cc: git, git, me, chakrabortyabhradeep79, Derrick Stolee

"Derrick Stolee via GitGitGadget" <gitgitgadget@gmail.com> writes:


> -		trace2_region_enter("pack-bitmap", "reading_lookup_table", the_repository);
>  		/* 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);

As "git blame" is bad in finding a piece of code that no longer
exists, it may make sense to leave a comment around here why we do
not have a trace2 region around this call, perhaps?

+	/* do not add trace2_region around here in the hot path */
	bitmap = lazy_bitmap_for_commit(...);

or something?

Thanks.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] pack-bitmap: remove trace2 region from hot path
  2022-09-23 17:05 ` Junio C Hamano
@ 2022-09-23 17:25   ` Junio C Hamano
  0 siblings, 0 replies; 10+ messages in thread
From: Junio C Hamano @ 2022-09-23 17:25 UTC (permalink / raw)
  To: Derrick Stolee via GitGitGadget
  Cc: git, git, me, chakrabortyabhradeep79, Derrick Stolee

Junio C Hamano <gitster@pobox.com> writes:

> "Derrick Stolee via GitGitGadget" <gitgitgadget@gmail.com> writes:
>
>
>> -		trace2_region_enter("pack-bitmap", "reading_lookup_table", the_repository);
>>  		/* 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);
>
> As "git blame" is bad in finding a piece of code that no longer
> exists, it may make sense to leave a comment around here why we do
> not have a trace2 region around this call, perhaps?
>
> +	/* do not add trace2_region around here in the hot path */
> 	bitmap = lazy_bitmap_for_commit(...);
>
> or something?
>
> Thanks.

Also, we'd need to disable t5310.150 that expects to see
reading_lookup_table label in the trace.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] pack-bitmap: remove trace2 region from hot path
  2022-09-23 13:00 [PATCH] pack-bitmap: remove trace2 region from hot path Derrick Stolee via GitGitGadget
  2022-09-23 17:05 ` Junio C Hamano
@ 2022-09-23 17:36 ` Junio C Hamano
  2022-09-23 18:07   ` Derrick Stolee
  2022-09-23 19:17   ` Taylor Blau
  2022-09-26 13:17 ` [PATCH v2] " Derrick Stolee via GitGitGadget
  2022-09-27 18:37 ` [PATCH] " Jeff Hostetler
  3 siblings, 2 replies; 10+ messages in thread
From: Junio C Hamano @ 2022-09-23 17:36 UTC (permalink / raw)
  To: Derrick Stolee via GitGitGadget
  Cc: git, git, me, chakrabortyabhradeep79, Derrick Stolee

"Derrick Stolee via GitGitGadget" <gitgitgadget@gmail.com> writes:

>     I noticed this while trying to backport the Abhradeep's lookup table
>     work into GitHub's fork. Something went wrong in that process, causing
>     this region to significantly slow down. It turns out that slow down does
>     not reproduce on current 'master', which is good. I must have missed
>     something while I was backporting.
>     
>     Regardless, the use of trace2_region_enter() here should be removed or
>     replaced. For the sake of 2.38.0, this simple removal is safe enough.

Well, not doing this removal is even safer, if we know that it is
not hurting in the -rc code.  It would be better than breaking our
tests without knowing ;-)  I am not upset that the patch broke the
test, by the way.  Compared to things silently breaking without
surfacing, a loud breakage in tests is a much easier thing to
handle.

My test run with the attached just finished, so that's what I am
going to queue tentatively on top.

Thanks.

 pack-bitmap.c           | 1 +
 t/t5310-pack-bitmaps.sh | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git c/pack-bitmap.c w/pack-bitmap.c
index 13457dd77e..a2bbbbd811 100644
--- c/pack-bitmap.c
+++ w/pack-bitmap.c
@@ -830,6 +830,7 @@ struct ewah_bitmap *bitmap_for_commit(struct bitmap_index *bitmap_git,
 		if (!bitmap_git->table_lookup)
 			return NULL;
 
+		/* this is a fairly hot codepath - no trace2_region please */
 		/* NEEDSWORK: cache misses aren't recorded */
 		bitmap = lazy_bitmap_for_commit(bitmap_git, commit);
 		if (!bitmap)
diff --git c/t/t5310-pack-bitmaps.sh w/t/t5310-pack-bitmaps.sh
index 7e50f8e765..2b1efc923b 100755
--- c/t/t5310-pack-bitmaps.sh
+++ w/t/t5310-pack-bitmaps.sh
@@ -455,7 +455,7 @@ 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' '
+: 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 &&

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH] pack-bitmap: remove trace2 region from hot path
  2022-09-23 17:36 ` Junio C Hamano
@ 2022-09-23 18:07   ` Derrick Stolee
  2022-09-23 19:17   ` Taylor Blau
  1 sibling, 0 replies; 10+ messages in thread
From: Derrick Stolee @ 2022-09-23 18:07 UTC (permalink / raw)
  To: Junio C Hamano, Derrick Stolee via GitGitGadget
  Cc: git, git, me, chakrabortyabhradeep79

On 9/23/2022 1:36 PM, Junio C Hamano wrote:
> "Derrick Stolee via GitGitGadget" <gitgitgadget@gmail.com> writes:
> 
>>     I noticed this while trying to backport the Abhradeep's lookup table
>>     work into GitHub's fork. Something went wrong in that process, causing
>>     this region to significantly slow down. It turns out that slow down does
>>     not reproduce on current 'master', which is good. I must have missed
>>     something while I was backporting.
>>     
>>     Regardless, the use of trace2_region_enter() here should be removed or
>>     replaced. For the sake of 2.38.0, this simple removal is safe enough.
> 
> Well, not doing this removal is even safer, if we know that it is
> not hurting in the -rc code.  It would be better than breaking our
> tests without knowing ;-)  I am not upset that the patch broke the
> test, by the way.  Compared to things silently breaking without
> surfacing, a loud breakage in tests is a much easier thing to
> handle.
> 
> My test run with the attached just finished, so that's what I am
> going to queue tentatively on top.

Whoops! I'm very sorry for not noticing that there was a test checking
for this trace. Your modification makes sense and I'll try to do a more
careful replacement of that test, if possible.

Thanks,
-Stolee

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] pack-bitmap: remove trace2 region from hot path
  2022-09-23 17:36 ` Junio C Hamano
  2022-09-23 18:07   ` Derrick Stolee
@ 2022-09-23 19:17   ` Taylor Blau
  1 sibling, 0 replies; 10+ messages in thread
From: Taylor Blau @ 2022-09-23 19:17 UTC (permalink / raw)
  To: Junio C Hamano
  Cc: Derrick Stolee via GitGitGadget, git, git, chakrabortyabhradeep79,
	Derrick Stolee

On Fri, Sep 23, 2022 at 10:36:44AM -0700, Junio C Hamano wrote:
> diff --git c/t/t5310-pack-bitmaps.sh w/t/t5310-pack-bitmaps.sh
> index 7e50f8e765..2b1efc923b 100755
> --- c/t/t5310-pack-bitmaps.sh
> +++ w/t/t5310-pack-bitmaps.sh
> @@ -455,7 +455,7 @@ 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' '
> +: 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 &&

Yeah, I would advocate for dropping this test entirely. That trace2
marker is the only indication that is so obvious that we're using the
lookup table to read bitmaps.

Perhaps the pack-bitmap helper could be taught to dump which extensions
it sees, and then write a test based on that? Although that isn't really
testing anything new, either, since we sometimes *notice* the extension
but don't actually read anything based on it (e.g., when disabled).

So I'd be content just dropping this.

Thanks,
Taylor

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH v2] pack-bitmap: remove trace2 region from hot path
  2022-09-23 13:00 [PATCH] pack-bitmap: remove trace2 region from hot path Derrick Stolee via GitGitGadget
  2022-09-23 17:05 ` Junio C Hamano
  2022-09-23 17:36 ` Junio C Hamano
@ 2022-09-26 13:17 ` Derrick Stolee via GitGitGadget
  2022-09-26 15:01   ` Ævar Arnfjörð Bjarmason
  2022-09-27 18:37 ` [PATCH] " Jeff Hostetler
  3 siblings, 1 reply; 10+ messages in thread
From: Derrick Stolee via GitGitGadget @ 2022-09-26 13:17 UTC (permalink / raw)
  To: git
  Cc: gitster, git, me, chakrabortyabhradeep79, Derrick Stolee,
	Derrick Stolee

From: Derrick Stolee <derrickstolee@github.com>

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>
---
    [For 2.38.0] pack-bitmap: remove trace2 region from hot path
    
    I noticed this while trying to backport the Abhradeep's lookup table
    work into GitHub's fork. Something went wrong in that process, causing
    this region to significantly slow down. It turns out that slow down does
    not reproduce on current 'master', which is good. I must have missed
    something while I was backporting.
    
    Regardless, the use of trace2_region_enter() here should be removed or
    replaced. For the sake of 2.38.0, this simple removal is safe enough.
    However, to really dig into what was happening I had to construct a
    rebase [2] of Jeff's trace2 stopwatch work, then apply changes on top
    [3] that could replace this region with trace2_timer_*() methods.
    
    [2]
    https://github.com/git/git/compare/master...derrickstolee:trace2-stopwatch
    [3]
    https://github.com/derrickstolee/git/compare/trace2-stopwatch...bitmap-trace2
    
    As a separate discussion, it might be worth revisiting that stopwatch
    work so we have it available as a tool when doing these kinds of
    investigations.
    
    
    Updates in v2
    =============
    
     * I removed the test that was checking for trace2 regions. In [3], I
       played around with using trace2_counter() to replace that check, so
       we could reinstate the test without the performance drop from using
       repeated trace2_region() calls.
     * I squashed in Junio's comment change.
    
    Thanks, -Stolee

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1365%2Fderrickstolee%2Fbitmap-remove-trace2-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1365/derrickstolee/bitmap-remove-trace2-v2
Pull-Request: https://github.com/gitgitgadget/git/pull/1365

Range-diff vs v1:

 1:  987827eaf90 ! 1:  8ef63c9e32f pack-bitmap: remove trace2 region from hot path
     @@ Commit message
      
          [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>
      
       ## pack-bitmap.c ##
     @@ pack-bitmap.c: struct ewah_bitmap *bitmap_for_commit(struct bitmap_index *bitmap
       			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);
     +
     + ## t/t5310-pack-bitmaps.sh ##
     +@@ t/t5310-pack-bitmaps.sh: 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 &&


 pack-bitmap.c           | 3 +--
 t/t5310-pack-bitmaps.sh | 7 -------
 2 files changed, 1 insertion(+), 9 deletions(-)

diff --git a/pack-bitmap.c b/pack-bitmap.c
index 9a208abc1fd..a2bbbbd811d 100644
--- a/pack-bitmap.c
+++ b/pack-bitmap.c
@@ -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);
diff --git a/t/t5310-pack-bitmaps.sh b/t/t5310-pack-bitmaps.sh
index 7e50f8e7653..6d693eef82f 100755
--- a/t/t5310-pack-bitmaps.sh
+++ b/t/t5310-pack-bitmaps.sh
@@ -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 &&

base-commit: 1b3d6e17fe83eb6f79ffbac2f2c61bbf1eaef5f8
-- 
gitgitgadget

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH v2] pack-bitmap: remove trace2 region from hot path
  2022-09-26 13:17 ` [PATCH v2] " Derrick Stolee via GitGitGadget
@ 2022-09-26 15:01   ` Ævar Arnfjörð Bjarmason
  2022-09-26 17:31     ` Derrick Stolee
  0 siblings, 1 reply; 10+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2022-09-26 15:01 UTC (permalink / raw)
  To: Derrick Stolee via GitGitGadget
  Cc: git, gitster, git, me, chakrabortyabhradeep79, Derrick Stolee


On Mon, Sep 26 2022, Derrick Stolee via GitGitGadget wrote:

> From: Derrick Stolee <derrickstolee@github.com>
>
> 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.

Just getting rid of this seems like a good thing for now.

But aside: Yes, one way to mitigate this rather than removing the
tracing would be to make it really fast.

But just skimming pack-bitmap.c do we really need trace2 at the
granularity of a single commit? Looking at who calls bitmap_for_commit()
wouldn't something like this sketch-out be much more useful?:
	
	diff --git a/pack-bitmap.c b/pack-bitmap.c
	index 9d5205055a5..439aec220c7 100644
	--- a/pack-bitmap.c
	+++ b/pack-bitmap.c
	@@ -830,10 +830,8 @@ 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);
	 		/* 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);
	@@ -1042,6 +1040,7 @@ static struct bitmap *find_objects(struct bitmap_index *bitmap_git,
	 	 * The ones without bitmaps in the index will be stored in the
	 	 * `not_mapped_list` for further processing.
	 	 */
	+	/* begin trace2 find roots? */
	 	while (roots) {
	 		struct object *object = roots->item;
	 		roots = roots->next;
	@@ -1055,6 +1054,7 @@ static struct bitmap *find_objects(struct bitmap_index *bitmap_git,
	 		object_list_insert(object, &not_mapped);
	 	}
	 
	+	/* end trace2 find roots? */
	 	/*
	 	 * Best case scenario: We found bitmaps for all the roots,
	 	 * so the resulting `or` bitmap has the full reachability analysis
	@@ -1100,7 +1100,7 @@ static struct bitmap *find_objects(struct bitmap_index *bitmap_git,
	 		incdata.base = base;
	 		incdata.seen = seen;
	 
	-		revs->include_check = should_include;
	+		revs->include_check = should_include; // Will call bitmap_for_commit()
	 		revs->include_check_obj = should_include_obj;
	 		revs->include_check_data = &incdata;
	 
	@@ -1110,9 +1110,11 @@ static struct bitmap *find_objects(struct bitmap_index *bitmap_git,
	 		show_data.bitmap_git = bitmap_git;
	 		show_data.base = base;
	 
	+		/* begin trace2 rev list? */
	 		traverse_commit_list(revs,
	 				     show_commit, show_object,
	 				     &show_data);
	+		/* end trace2 rev list? */
	 
	 		revs->include_check = NULL;
	 		revs->include_check_obj = NULL;
	

This is *not* the same as stricking the tracing into
bitmap_for_commit(), but do we really need the tracing that far inside
our loop?


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2] pack-bitmap: remove trace2 region from hot path
  2022-09-26 15:01   ` Ævar Arnfjörð Bjarmason
@ 2022-09-26 17:31     ` Derrick Stolee
  0 siblings, 0 replies; 10+ messages in thread
From: Derrick Stolee @ 2022-09-26 17:31 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason,
	Derrick Stolee via GitGitGadget
  Cc: git, gitster, git, me, chakrabortyabhradeep79

On 9/26/2022 11:01 AM, Ævar Arnfjörð Bjarmason wrote:
> 
> On Mon, Sep 26 2022, Derrick Stolee via GitGitGadget wrote:
> 
>> 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.
> 
> Just getting rid of this seems like a good thing for now.
> 
> But aside: Yes, one way to mitigate this rather than removing the
> tracing would be to make it really fast.
> 
> But just skimming pack-bitmap.c do we really need trace2 at the
> granularity of a single commit? Looking at who calls bitmap_for_commit()
> wouldn't something like this sketch-out be much more useful?:

The point of it being where it was to check that we hit the path
custom to the commit lookup extension, hence the test that is removed.

You are proposing a different region entirely, meant to measure the
cost of the entire walk. Maybe that's valuable, but not critical to
this topic.

If you're proposing the high-level traces as an alternative to my
prototype using the trace2 timers, then I'll point out that the timer
approach allows us to determine how much time is being spent checking
for bitmaps versus walking commits, which the regions you provided don't.

Thanks,
-Stolee

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] pack-bitmap: remove trace2 region from hot path
  2022-09-23 13:00 [PATCH] pack-bitmap: remove trace2 region from hot path Derrick Stolee via GitGitGadget
                   ` (2 preceding siblings ...)
  2022-09-26 13:17 ` [PATCH v2] " Derrick Stolee via GitGitGadget
@ 2022-09-27 18:37 ` Jeff Hostetler
  3 siblings, 0 replies; 10+ messages in thread
From: Jeff Hostetler @ 2022-09-27 18:37 UTC (permalink / raw)
  To: Derrick Stolee via GitGitGadget, git
  Cc: gitster, me, chakrabortyabhradeep79, Derrick Stolee



On 9/23/22 9:00 AM, Derrick Stolee via GitGitGadget wrote:
> From: Derrick Stolee <derrickstolee@github.com>
> 
> 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/

I'll dust off my "timers and counters" series, address the
various issues that were raised back in December, and resubmit.

Thanks for the reminder.
Jeff


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2022-09-27 18:37 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-23 13:00 [PATCH] pack-bitmap: remove trace2 region from hot path Derrick Stolee via GitGitGadget
2022-09-23 17:05 ` Junio C Hamano
2022-09-23 17:25   ` Junio C Hamano
2022-09-23 17:36 ` Junio C Hamano
2022-09-23 18:07   ` Derrick Stolee
2022-09-23 19:17   ` Taylor Blau
2022-09-26 13:17 ` [PATCH v2] " Derrick Stolee via GitGitGadget
2022-09-26 15:01   ` Ævar Arnfjörð Bjarmason
2022-09-26 17:31     ` Derrick Stolee
2022-09-27 18:37 ` [PATCH] " Jeff Hostetler

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).