git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] commit.h: rearrange 'index' to shrink struct commit

From
Junio C Hamano <gitster@pobox.com>
Date
May 13, 2018, 02:03 UTC
Message-ID
<xmqqmux4e2gq.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<20180511172054.7684-1-pclouds@gmail.com>
Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:
Show 28 quoted lines
> On linux 64-bit architecture, pahole finds that there's a 4 bytes
> padding after 'index'. Moving it to the end reduces this struct's size
> from 72 to 64 bytes (because of another 4 bytes padding after
> graph_pos). On linux 32-bit, the struct size remains 52 bytes like
> before.
>
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> ---
>  commit.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/commit.h b/commit.h
> index e57ae4b583..fd1cbe7263 100644
> --- a/commit.h
> +++ b/commit.h
> @@ -19,11 +19,11 @@ struct commit_list {
>  struct commit {
>  	struct object object;
>  	void *util;
> -	unsigned int index;
>  	timestamp_t date;
>  	struct commit_list *parents;
>  	struct tree *tree;
>  	uint32_t graph_pos;
> +	unsigned int index;
>  };
>  
>  extern int save_commit_buffer;
Quite nice.
Previous: Nguyễn Thái Ngọc Duy
Message 2 of 2 in “commit.h: rearrange 'index' to shrink struct commit”
  1. commit.h: rearrange 'index' to shrink struct commitNguyễn Thái Ngọc Duy, May 11, 2018
  2. Junio C HamanoMay 13, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.