]> git.ipfire.org Git - thirdparty/git.git/commit - builtin/index-pack.c
index-pack: reduce object_entry size to save memory
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>
Thu, 26 Feb 2015 10:52:07 +0000 (17:52 +0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 27 Feb 2015 20:23:25 +0000 (12:23 -0800)
commit417305764a90eaf100faaa9ca46cd76ed6b3bcb6
treebc2b140fda8e5c3fdf2b109f07fc4482c9a19f23
parent9874fca7122563e28d699a911404fc49d2a24f1c
index-pack: reduce object_entry size to save memory

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 memory use for basic bookkeeping (**),
about 16%.

(*) linux-2.6.git already has 4M objects as of v3.19-rc7 so this is
not an unrealistic number of objects that we have to deal with.

(**)  3.4M * (sizeof(object_entry) + sizeof(delta_entry)) = 311MB

Brought-up-by: Matthew Sporleder <msporleder@gmail.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/index-pack.c