git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "René Scharfe" <l.s.r@web.de>
To: "brian m. carlson" <sandals@crustytoothpaste.net>,
	Michael Ward <mward@smartsoftwareinc.com>,
	git@vger.kernel.org, Derrick Stolee <dstolee@microsoft.com>
Cc: Jeff King <peff@peff.net>
Subject: Re: Git 2 force commits but Git 1 doesn't
Date: Tue, 23 Jun 2020 18:42:48 +0200	[thread overview]
Message-ID: <83e99359-2c24-d8cd-bd4a-6ba90ed54b7f@web.de> (raw)
In-Reply-To: <20200623151951.GS6531@camp.crustytoothpaste.net>

Am 23.06.20 um 17:30 schrieb brian m. carlson:
> On 2020-06-23 at 08:59:28, René Scharfe wrote:
>> How could we possibly check that?  Perhaps by having a commit flag
>> register (a global unsigned int) and having functions announce their
>> bits in it.  Colliding announcements would BUG().
>
> By my count, we have only 88 individual bits used.  If we moved all of
> the builtin functions plus upload-pack (which shouldn't overlap) to a
> single range, that would account for 53 bits, which would leave us 35
> bits for all the rest of the code.  Since we need at most 27 bits for a
> builtin command, if we used a 64-bit integer, we'd have space for all
> the remaining bits not to overlap, plus bits for the type and flags
> bits.
>
> Since we'd be doing only bit operations on the flags variable, the
> performance impact on 32-bit systems would be very minimal, although
> we'd allocate an extra 4 bytes for struct object.  I don't know if
> that's a problem.

How many objects would we load into memory?  4 bytes would be OK if
multiplied by a million or so (like in the Linux repo), but billions
might cause problems.

The switch from SHA1 to SHA256 is going to add 12 bytes per object, so
that might be a way to find out what happens if we add 4 bytes on top.

We could save 4 bytes on x64 by reducing FLAG_BITS from 29 to 28, by the
way.  Increasing it to 32 would be free.  That's because parsed (1),
type (3) and flags (29) currently occupy 33 bits, which are padded to 8
bytes.  And bits 22-24 are only used by builtin/show-branch.c, so it
should be easy to tighten the flags range just a bit.  Weird.

Why do we have object flags and not commit flags anyway?  (I may have
asked that before, but can't find the answer..)

> Assuming we don't want to do that right now, may I have your sign-off
> for the following code, René, so I can add it to a patch along with my
> test?
>
>> diff --git a/http-push.c b/http-push.c
>> index 822f326599..99adbebdcf 100644
>> --- a/http-push.c
>> +++ b/http-push.c
>> @@ -70,10 +70,10 @@ enum XML_Status {
>>  #define LOCK_REFRESH 30
>>
>>  /* Remember to update object flag allocation in object.h */
>> -#define LOCAL    (1u<<16)
>> -#define REMOTE   (1u<<17)
>> -#define FETCHING (1u<<18)
>> -#define PUSHING  (1u<<19)
>> +#define LOCAL    (1u<<11)
>> +#define REMOTE   (1u<<12)
>> +#define FETCHING (1u<<13)
>> +#define PUSHING  (1u<<14)
>>
>>  /* We allow "recursive" symbolic refs. Only within reason, though */
>>  #define MAXDEPTH 5
>> diff --git a/object.h b/object.h
>> index b22328b838..a496d2e4e1 100644
>> --- a/object.h
>> +++ b/object.h
>> @@ -67,7 +67,7 @@ struct object_array {
>>   * builtin/blame.c:                        12-13
>>   * bisect.c:                                        16
>>   * bundle.c:                                        16
>> - * http-push.c:                                     16-----19
>> + * http-push.c:                          11-----14
>>   * commit-graph.c:                                15
>>   * commit-reach.c:                                  16-----19
>>   * sha1-name.c:                                              20
>>

You're welcome to use it.  Not sure if a sign-off is necessary, but
here you have it:

Signed-off-by: René Scharfe <l.s.r@web.de>


  reply	other threads:[~2020-06-23 16:43 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-22 19:40 Git 2 force commits but Git 1 doesn't Michael Ward
2020-06-22 20:21 ` brian m. carlson
2020-06-22 20:30   ` Michael Ward
2020-06-22 20:31     ` Michael Ward
2020-06-22 20:43     ` brian m. carlson
2020-06-22 20:52       ` Michael Ward
2020-06-22 21:09         ` brian m. carlson
2020-06-22 22:17           ` Michael Ward
2020-06-23  1:05             ` brian m. carlson
2020-06-23  8:59               ` René Scharfe
2020-06-23 15:30                 ` brian m. carlson
2020-06-23 16:42                   ` René Scharfe [this message]
2020-06-23 19:13                     ` brian m. carlson
2020-06-24 13:05                     ` René Scharfe
2020-06-23 20:21               ` [PATCH] http-push: ensure unforced pushes fail when data would be lost brian m. carlson
2020-06-23 21:28                 ` Eric Sunshine
2020-06-23 21:50                   ` brian m. carlson
2020-06-23 21:52                 ` [PATCH v2] " brian m. carlson
2020-06-23 22:41                   ` Junio C Hamano

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=83e99359-2c24-d8cd-bd4a-6ba90ed54b7f@web.de \
    --to=l.s.r@web.de \
    --cc=dstolee@microsoft.com \
    --cc=git@vger.kernel.org \
    --cc=mward@smartsoftwareinc.com \
    --cc=peff@peff.net \
    --cc=sandals@crustytoothpaste.net \
    /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).