From: Junio C Hamano <gitster@pobox•com>
To: "Nguyễn Thái Ngọc Duy" <pclouds@gmail•com>
Cc: git@vger•kernel.org, msporleder@gmail•com
Subject: Re: [PATCH] index-pack: reduce memory footprint a bit
Date: Mon, 09 Feb 2015 11:27:21 -0800 [thread overview]
Message-ID: <xmqqfvaec2cm.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <1423487929-28019-1-git-send-email-pclouds@gmail.com> ("Nguyễn Thái Ngọc Duy"'s message of "Mon, 9 Feb 2015 20:18:49 +0700")
Nguyễn Thái Ngọc Duy <pclouds@gmail•com> writes:
> For each object in the input pack, we need one struct object_entry. On
> x86-64, this struct is 64 bytes long. Although:
>
> - The 8 bytes for delta_depth and base_object_no are only useful when
> show_stat is set. And it's never set unless someone is debugging.
>
> - The three fields hdr_size, type and real_type take 4 bytes each
> even though they never use more than 4 bits.
>
> By moving delta_depth and base_object_no out of struct object_entry
> and make the other 3 fields one byte long instead of 4, we shrink 25%
> of this struct.
>
> On a 3.4M object repo that's about 53MB. The saving is less impressive
> compared to index-pack total memory use (about 400MB before delta
> resolving, so the saving is just 13%)
>
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail•com>
> ---
> I'm not sure if this patch is worth pursuing. It makes the code a
> little bit harder to read. I was just wondering how much memory could
> be saved..
I would say 13% is already impressive ;-).
I do not find the result all that harder to read. I however think
that the change would make it a lot harder to maintain, especially
because the name "object-entry-extra" does not have any direct link
to "show-stat" to hint us that this must be allocated when show-stat
is in use and must never be looked at when show-stat is not in use.
Also it makes me wonder if the compilers are smart enough to notice
that the codepaths that access objects_extra[] are OK because they
are all inside "if (show_stat)".
next prev parent reply other threads:[~2015-02-09 19:27 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-08 16:10 low memory system to clone larger repo matthew sporleder
2015-02-09 10:40 ` Duy Nguyen
2015-02-09 11:20 ` Matt Sporleder
2015-02-09 12:32 ` Duy Nguyen
2015-02-09 13:18 ` [PATCH] index-pack: reduce memory footprint a bit Nguyễn Thái Ngọc Duy
2015-02-09 19:27 ` Junio C Hamano [this message]
2015-02-10 9:30 ` Duy Nguyen
2015-02-10 12:08 ` matthew sporleder
2015-02-10 18:49 ` Junio C Hamano
2015-02-11 13:01 ` matthew sporleder
2015-02-11 13:10 ` Duy Nguyen
2015-02-10 3:56 ` low memory system to clone larger repo matthew sporleder
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=xmqqfvaec2cm.fsf@gitster.dls.corp.google.com \
--to=gitster@pobox$(echo .)com \
--cc=git@vger$(echo .)kernel.org \
--cc=msporleder@gmail$(echo .)com \
--cc=pclouds@gmail$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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