git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ben Peart <peartben@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: Ben Peart <benpeart@microsoft.com>,
	git@vger.kernel.org, chriscool@tuxfamily.org,
	t.gummerer@gmail.com, l.s.r@web.de, jsorianopastor@gmail.com,
	peff@peff.net, Johannes Schindelin <johannes.schindelin@gmx.de>
Subject: Re: [PATCH v2] read_index_from(): Skip verification of the cache entry order to speed index loading
Date: Tue, 31 Oct 2017 08:51:59 -0400	[thread overview]
Message-ID: <8e268809-b596-fd1c-1f39-e040743596cb@gmail.com> (raw)
In-Reply-To: <xmqq8tfs3x3m.fsf@gitster.mtv.corp.google.com>



On 10/30/2017 9:49 PM, Junio C Hamano wrote:
> Ben Peart <peartben@gmail.com> writes:
> 
>> Any updates or thoughts on this one?  While the patch has become quite
>> trivial, it does results in a savings of 5%-15% in index load time.
>>
>> I thought the compromise of having this test only run when DEBUG is
>> defined should limit it to developer builds (hopefully everyone
>> developing on git is running DEBUG builds :)).  Since the test is
>> trying to detect buggy code when writing the index, I thought that was
>> the right time to test/catch any issues.
> 
> This check is more about catching a possible breakage (and a
> malicious repository) early before we go too far into the operation.
> I do not think this check is about debugging the implementation of
> Git.  How would it be useful to turn it on in DEBUG build?
> 
> While I do think pursuing any runtime improvements better than a
> couple of percents is worth it, I do not think the approach taken by
> this iteration makes much sense; the previous one that at least
> allowed fsck to catch breakage may have been already too leaky to
> catch real issues (i.e. when you are asked to visit and look at an
> unknown repository, you wouldn't start your session with "git fsck"
> to protect yourself), and this round makes it much worse.
> 
> Besides, I see no -DDEBUG from "grep -e '-D[A-Z]*DEBUG' Makefile".
> If this check were about allowing us easier time debugging the
> binary (which I do not think it is), this probably should be
> '#ifndef NDEBUG' instead.
> 

I've tried 3 different ways to remove the overhead of this call from 
regular git operations.

The first was version 1 of the patch which had fsck catch breakage but 
removed it from other commands that read the index.  Since that version 
was not accepted, I took the feedback "I think I like the direction of 
getting rid of the order in post_read_index_from(), not only during the 
normal but also in fsck" to come up with a version 2.

I was hesitant to remove the code completely as I did believe it had 
some value in detecting invalid indexes so went looking for a macro I 
could use to have it 1) not happen during regular user commands but 2) 
still happen for developers.

The NDEBUG macro is guaranteed by the C89 standard 
(http://port70.net/~nsz/c/c89/c89-draft.html#4.1.2 ) to guard the code 
that is only necessary when assertions are in effect so seemed like a 
good choice.  When I used it however, I discovered that the git Makefile 
does not define NDEBUG so using this macro did not have any effect thus 
making the patch useless as the code continues to run in all cases.

On a side note, there are 434 instances of assert which up until this 
experience I believed were being removed in released builds.  As far as 
I can tell, that is not the case.  If removing them is the 
desired/expected behavior, we need to fix our Makefile as it only 
currently defines NDEBUG if USE_NED_ALLOCATOR is defined.

I then searched the code and found 47 instances where the macro DEBUG 
was used.  I (incorrectly) assumed that meant it must be used by other 
git developers.  I personally have a build alias that adds "-j12 
CFLAGS=-DDEBUG" to my make command but apparently I'm in the minority. :)

This assumption led me to the patch version 2 (guarding the code with 
#ifdef DEBUG) as it does meet the request to remove it during normal but 
also fsck and does so with regular/release builds as they are currently 
defined.

It seems that the current round of feedback is more in favor of leaving 
the test in fsck but removing it for other commands.  If that is the 
desired behavior, please use version 1 of the patch.

I'm also happy to flip this to "#ifndef NDEBUG" but that only makes 
sense if the released builds actually set NDEBUG which (I believe) will 
require a patch to Makefile.


      reply	other threads:[~2017-10-31 12:52 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-18 14:27 [PATCH v1] read_index_from(): Skip verification of the cache entry order to speed index loading Ben Peart
2017-10-19  5:22 ` Junio C Hamano
2017-10-19 15:12   ` Ben Peart
2017-10-19 16:05     ` Jeff King
2017-10-20  1:14       ` Junio C Hamano
2017-10-19 22:14     ` Stefan Beller
2017-10-20 12:47       ` Johannes Schindelin
2017-10-20 18:53         ` Stefan Beller
2017-10-21  1:55           ` Junio C Hamano
2017-10-24 14:45 ` [PATCH v2] " Ben Peart
2017-10-30 12:48   ` Ben Peart
2017-10-30 18:03     ` Jeff King
2017-10-31  0:33       ` Alex Vandiver
2017-10-31 13:01         ` Ben Peart
2017-10-31 17:10           ` Jeff King
2017-11-01  6:09             ` Junio C Hamano
2017-10-31  1:49     ` Junio C Hamano
2017-10-31 12:51       ` Ben Peart [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8e268809-b596-fd1c-1f39-e040743596cb@gmail.com \
    --to=peartben@gmail.com \
    --cc=benpeart@microsoft.com \
    --cc=chriscool@tuxfamily.org \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=johannes.schindelin@gmx.de \
    --cc=jsorianopastor@gmail.com \
    --cc=l.s.r@web.de \
    --cc=peff@peff.net \
    --cc=t.gummerer@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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 NNTP newsgroup(s).