Git development
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Kristofer Karlsson via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org,  Derrick Stolee <stolee@gmail.com>,
	 Kristofer Karlsson <krka@spotify.com>
Subject: Re: [PATCH v2] commit: remove padding from struct commit
Date: Fri, 13 Nov 2026 09:13:35 -0800	[thread overview]
Message-ID: <xmqq7bigfydc.fsf@gitster.g> (raw)
In-Reply-To: <pull.2309.v2.git.1794576606249.gitgitgadget@gmail.com> (Kristofer Karlsson via GitGitGadget's message of "Fri, 13 Nov 2026 13:30:06 +0000")

"Kristofer Karlsson via GitGitGadget" <gitgitgadget@gmail.com>
writes:

> Since the order of the members no longer reflects their importance,

Micronit: "no longer reflects logical grouping or impotance" or
something, just like you already have in the comment in the header
file.

> diff --git a/commit.h b/commit.h
> index 1061ed791b..d43cb1e46d 100644
> --- a/commit.h
> +++ b/commit.h
> @@ -23,10 +23,30 @@ struct commit_list {
>   * The size of this struct matters in full repo walk operations like
>   * 'git clone' or 'git gc'. Consider using commit-slab to attach data
>   * to a commit instead of adding new fields here.
> + *
> + * The order of the members is partly chosen to keep the memory layout
> + * compact (avoiding alignment padding), and does not necessarily
> + * reflect their importance or grouping.
>   */
>  struct commit {
> +	/*
> +	 * Must be the first member, so that a "struct object *" can be
> +	 * cast to a "struct commit *".
> +	 */

Either append "... when we know it is a commit", swap the order, or
do both.  My preference is the second one which would leave the
shortest result.

>  	struct object object;
> +
> +	/*
> +	 * Index into the commit-slab arrays: unique per in-core commit,
> +	 * and only meaningful within the current process.
> +	 */
> +	unsigned int index;

Nice.  It is on a rather longer side and "and only meaningful..."
may be redundant after saying "in-core", but nothing is wrong.

Thanks.  Will queue.

      parent reply	other threads:[~2026-11-13 17:13 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-12 16:14 [PATCH] commit: remove padding from struct commit Kristofer Karlsson via GitGitGadget
2026-11-12 18:00 ` Derrick Stolee
2026-11-12 21:46   ` Kristofer Karlsson
2026-11-12 19:22 ` Junio C Hamano
2026-11-12 21:35   ` Kristofer Karlsson
2026-11-13 15:31     ` Oswald Buddenhagen
2026-11-13 13:30 ` [PATCH v2] " Kristofer Karlsson via GitGitGadget
2026-11-13 14:57   ` Derrick Stolee
2026-11-13 15:41     ` Kristofer Karlsson
2026-11-13 16:52       ` Junio C Hamano
2026-11-13 17:13   ` Junio C Hamano [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=xmqq7bigfydc.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=krka@spotify.com \
    --cc=stolee@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