git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] commit.h: rearrange 'index' to shrink struct commit
@ 2018-05-11 17:20 Nguyễn Thái Ngọc Duy
  2018-05-13  2:03 ` Junio C Hamano
  0 siblings, 1 reply; 2+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-05-11 17:20 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

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;
-- 
2.17.0.705.g3525833791


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

* Re: [PATCH] commit.h: rearrange 'index' to shrink struct commit
  2018-05-11 17:20 [PATCH] commit.h: rearrange 'index' to shrink struct commit Nguyễn Thái Ngọc Duy
@ 2018-05-13  2:03 ` Junio C Hamano
  0 siblings, 0 replies; 2+ messages in thread
From: Junio C Hamano @ 2018-05-13  2:03 UTC (permalink / raw)
  To: Nguyễn Thái Ngọc Duy; +Cc: git

Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:

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

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

end of thread, other threads:[~2018-05-13  2:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-11 17:20 [PATCH] commit.h: rearrange 'index' to shrink struct commit Nguyễn Thái Ngọc Duy
2018-05-13  2:03 ` 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).