git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] fast-import: Don't count delta attempts against an empty buffer
@ 2018-06-30 21:41 Mike Hommey
  2018-07-03 18:41 ` Junio C Hamano
  0 siblings, 1 reply; 4+ messages in thread
From: Mike Hommey @ 2018-06-30 21:41 UTC (permalink / raw)
  To: git; +Cc: gitster

When the reference buffer is empty, diff_delta returns NULL without
really attempting anything, yet fast-import counts that as a delta
attempt.

Signed-off-by: Mike Hommey <mh@glandium.org>
---
 fast-import.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fast-import.c b/fast-import.c
index 4d55910ab9..12195d54d7 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -1076,7 +1076,7 @@ static int store_object(
 		return 1;
 	}
 
-	if (last && last->data.buf && last->depth < max_depth
+	if (last && last->data.len && last->data.buf && last->depth < max_depth
 		&& dat->len > the_hash_algo->rawsz) {
 
 		delta_count_attempts_by_type[type]++;
-- 
2.18.0


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

* Re: [PATCH] fast-import: Don't count delta attempts against an empty buffer
  2018-06-30 21:41 [PATCH] fast-import: Don't count delta attempts against an empty buffer Mike Hommey
@ 2018-07-03 18:41 ` Junio C Hamano
  2018-07-03 21:59   ` Mike Hommey
  0 siblings, 1 reply; 4+ messages in thread
From: Junio C Hamano @ 2018-07-03 18:41 UTC (permalink / raw)
  To: Mike Hommey; +Cc: git

Mike Hommey <mh@glandium.org> writes:

> When the reference buffer is empty, diff_delta returns NULL without
> really attempting anything, yet fast-import counts that as a delta
> attempt.

But that is an attempt nevertheless, no?  Attempted and failed to
find anything useful, that is.  What problem are you trying to solve
and what issue are you trying to address, exactly?

... goes and reads the patch ...

> Signed-off-by: Mike Hommey <mh@glandium.org>
> ---
>  fast-import.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fast-import.c b/fast-import.c
> index 4d55910ab9..12195d54d7 100644
> --- a/fast-import.c
> +++ b/fast-import.c
> @@ -1076,7 +1076,7 @@ static int store_object(
>  		return 1;
>  	}
>  
> -	if (last && last->data.buf && last->depth < max_depth
> +	if (last && last->data.len && last->data.buf && last->depth < max_depth
>  		&& dat->len > the_hash_algo->rawsz) {
>  
>  		delta_count_attempts_by_type[type]++;

This is a misleading patch as the title and the proposed log message
both talk about "attempts are counted but we didn't actually do
anything", implying that the only problem is that the counter is not
aligned with reality.  The fact that the post-context we see here
only shows the "counting" part does not help us, either.

But the next line in the post-context is actually code that does
something important, which is ...

		delta = diff_delta(last->data.buf, last->data.len,
			dat->buf, dat->len,
			&deltalen, dat->len - the_hash_algo->rawsz);
	} else
		delta = NULL;


... and makes the reader realize that the change itself is much
better than the patch with 3-line context, the title, and the
proposed log message advertises it as ;-)

How about selling it this way instead?

	fast-import: do not call diff_delta() with empty buffer

	We know diff_delta() returns NULL, saying "no good delta
	exists for it", when fed an empty data.  Check the length of
	the data in the caller to avoid such a call.  

	This incidentally reduces the number of attempted deltification
	we see in the final statistics.

or something like that?

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

* Re: [PATCH] fast-import: Don't count delta attempts against an empty buffer
  2018-07-03 18:41 ` Junio C Hamano
@ 2018-07-03 21:59   ` Mike Hommey
  2018-07-06 16:45     ` Junio C Hamano
  0 siblings, 1 reply; 4+ messages in thread
From: Mike Hommey @ 2018-07-03 21:59 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

On Tue, Jul 03, 2018 at 11:41:42AM -0700, Junio C Hamano wrote:
> Mike Hommey <mh@glandium.org> writes:
> 
> > When the reference buffer is empty, diff_delta returns NULL without
> > really attempting anything, yet fast-import counts that as a delta
> > attempt.
> 
> But that is an attempt nevertheless, no?  Attempted and failed to
> find anything useful, that is.  What problem are you trying to solve
> and what issue are you trying to address, exactly?
> 
> ... goes and reads the patch ...
> 
> > Signed-off-by: Mike Hommey <mh@glandium.org>
> > ---
> >  fast-import.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/fast-import.c b/fast-import.c
> > index 4d55910ab9..12195d54d7 100644
> > --- a/fast-import.c
> > +++ b/fast-import.c
> > @@ -1076,7 +1076,7 @@ static int store_object(
> >  		return 1;
> >  	}
> >  
> > -	if (last && last->data.buf && last->depth < max_depth
> > +	if (last && last->data.len && last->data.buf && last->depth < max_depth
> >  		&& dat->len > the_hash_algo->rawsz) {
> >  
> >  		delta_count_attempts_by_type[type]++;
> 
> This is a misleading patch as the title and the proposed log message
> both talk about "attempts are counted but we didn't actually do
> anything", implying that the only problem is that the counter is not
> aligned with reality.  The fact that the post-context we see here
> only shows the "counting" part does not help us, either.
> 
> But the next line in the post-context is actually code that does
> something important, which is ...
> 
> 		delta = diff_delta(last->data.buf, last->data.len,
> 			dat->buf, dat->len,
> 			&deltalen, dat->len - the_hash_algo->rawsz);
> 	} else
> 		delta = NULL;
> 
> 
> ... and makes the reader realize that the change itself is much
> better than the patch with 3-line context, the title, and the
> proposed log message advertises it as ;-)
> 
> How about selling it this way instead?
> 
> 	fast-import: do not call diff_delta() with empty buffer
> 
> 	We know diff_delta() returns NULL, saying "no good delta
> 	exists for it", when fed an empty data.  Check the length of
> 	the data in the caller to avoid such a call.  
> 
> 	This incidentally reduces the number of attempted deltification
> 	we see in the final statistics.
> 
> or something like that?

Fair enough. Do you want me to send a v2 with this description?

Mike

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

* Re: [PATCH] fast-import: Don't count delta attempts against an empty buffer
  2018-07-03 21:59   ` Mike Hommey
@ 2018-07-06 16:45     ` Junio C Hamano
  0 siblings, 0 replies; 4+ messages in thread
From: Junio C Hamano @ 2018-07-06 16:45 UTC (permalink / raw)
  To: Mike Hommey; +Cc: git

Mike Hommey <mh@glandium.org> writes:

> On Tue, Jul 03, 2018 at 11:41:42AM -0700, Junio C Hamano wrote:
>> Mike Hommey <mh@glandium.org> writes:
>> 
>> > When the reference buffer is empty, diff_delta returns NULL without
>> > really attempting anything, yet fast-import counts that as a delta
>> > attempt.
>> 
>> But that is an attempt nevertheless, no?  Attempted and failed to
>> find anything useful, that is.  What problem are you trying to solve
>> and what issue are you trying to address, exactly?
>> 
>> ... goes and reads the patch ...
>> 
>> > Signed-off-by: Mike Hommey <mh@glandium.org>
>> > ---
>> >  fast-import.c | 2 +-
>> >  1 file changed, 1 insertion(+), 1 deletion(-)
>> >
>> > diff --git a/fast-import.c b/fast-import.c
>> > index 4d55910ab9..12195d54d7 100644
>> > --- a/fast-import.c
>> > +++ b/fast-import.c
>> > @@ -1076,7 +1076,7 @@ static int store_object(
>> >  		return 1;
>> >  	}
>> >  
>> > -	if (last && last->data.buf && last->depth < max_depth
>> > +	if (last && last->data.len && last->data.buf && last->depth < max_depth
>> >  		&& dat->len > the_hash_algo->rawsz) {
>> >  
>> >  		delta_count_attempts_by_type[type]++;
>> 
>> This is a misleading patch as the title and the proposed log message
>> both talk about "attempts are counted but we didn't actually do
>> anything", implying that the only problem is that the counter is not
>> aligned with reality.  The fact that the post-context we see here
>> only shows the "counting" part does not help us, either.
>> 
>> But the next line in the post-context is actually code that does
>> something important, which is ...
>> 
>> 		delta = diff_delta(last->data.buf, last->data.len,
>> 			dat->buf, dat->len,
>> 			&deltalen, dat->len - the_hash_algo->rawsz);
>> 	} else
>> 		delta = NULL;
>> 
>> 
>> ... and makes the reader realize that the change itself is much
>> better than the patch with 3-line context, the title, and the
>> proposed log message advertises it as ;-)
>> 
>> How about selling it this way instead?
>> 
>> 	fast-import: do not call diff_delta() with empty buffer
>> 
>> 	We know diff_delta() returns NULL, saying "no good delta
>> 	exists for it", when fed an empty data.  Check the length of
>> 	the data in the caller to avoid such a call.  
>> 
>> 	This incidentally reduces the number of attempted deltification
>> 	we see in the final statistics.
>> 
>> or something like that?
>
> Fair enough. Do you want me to send a v2 with this description?

For a single-patch topic like this one, if you like what was in the
e-mail verbatim, saying so is sufficient, as I can just use the
material to run "git commit --amend".  For anything more involved
(e.g. "oh, then insert a code to do this before that function"
and/or a fix to an earlier patch in a multi-patch series), I'd
prefer a re-submission, which can be processed just the same way as
any other new topic.

Thanks.



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

end of thread, other threads:[~2018-07-06 16:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-30 21:41 [PATCH] fast-import: Don't count delta attempts against an empty buffer Mike Hommey
2018-07-03 18:41 ` Junio C Hamano
2018-07-03 21:59   ` Mike Hommey
2018-07-06 16:45     ` Junio C Hamano

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).