Re: [PATCH/RFC v3 08/12] pack-objects: refer to delta objects by index instead of pointer
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Mar 14, 2018, 16:18 UTC
- Message-ID
- <xmqqy3iuzl3i.fsf@gitster-ct.c.googlers.com>
- In-Reply-To
- <20180308114232.10508-9-pclouds@gmail.com>
Nguyễn Thái Ngọc Duy <pclouds@gmail.com> writes:
> Notice that packing_data::nr_objects is uint32_t, we could only handle > maximum 4G objects and can address all of them with an uint32_t. If we > use a pointer here, we waste 4 bytes on 64 bit architecture.
Some things are left unsaid or left unclear and make readers stutter a bit while reading this paragraph. We can address them with uint32_t only because we happen to have a linear array of all objects involved already, i.e. the pack->objects[] array. The readers are forced to rephrase the above in their mind
... and each of them can be identified with an uint32_t. Because we have all of these objects in pack->objects[], we can replace the "delta" field in each object entry that points at its delta base object with uint32_t index into this array to save memory (on 64-bit arch, 8-byte pointer gets shrunk to 4-byte uint).
or something like that before understanding why this is a valid memory footprint optimization.