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

Re: [PATCH] index-pack: reduce memory footprint a bit

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 9, 2015, 19:27 UTC
Message-ID
<xmqqfvaec2cm.fsf@gitster.dls.corp.google.com>
In-Reply-To
<1423487929-28019-1-git-send-email-pclouds@gmail.com>
Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:
Show 22 quoted lines
> 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)".

Previous: Nguyễn Thái Ngọc DuyNext: Duy Nguyen
Message 6 of 12 in “low memory system to clone larger repo”
  1. matthew sporlederJan 8, 2015
  2. Duy NguyenFeb 9, 2015
  3. Matt SporlederFeb 9, 2015
  4. Duy NguyenFeb 9, 2015
  5. index-pack: reduce memory footprint a bitNguyễn Thái Ngọc Duy, Feb 9, 2015
  6. Junio C HamanoFeb 9, 2015
  7. Duy NguyenFeb 10, 2015
  8. matthew sporlederFeb 10, 2015
  9. Junio C HamanoFeb 10, 2015
  10. matthew sporlederFeb 11, 2015
  11. Duy NguyenFeb 11, 2015
  12. matthew sporlederFeb 10, 2015

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.