{"thread":{"id":"7570","subject":"[PATCH 1/8] git-repack --max-pack-size: Add new file statics and struct fields","startedAt":"2007-04-08T23:19:33Z","lastAt":"2007-04-09T18:38:34Z","messageCount":3,"participants":["Dana How","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":8},"messages":[{"id":"38888","messageId":"46197885.3060502@gmail.com","threadId":"7570","inReplyTo":null,"subject":"[PATCH 1/8] git-repack --max-pack-size: Add new file statics and struct fields","fromName":"Dana How","fromEmail":"danahow@gmail.com","sentAt":"2007-04-08T23:19:33Z","receivedAt":"2007-04-08T23:19:33Z","isPatch":true,"sender":{"key":"danahow@gmail.com","avatar":null},"body":"\nThis adds \"offset_limit\", which will contain the limit\nspecified by --max-pack-size, \"written_list\", the actual\nlist of objects written to the current pack, and \"nr_written\",\nthe number of objects in written_list.  \"prev_pack\" is\nadded to struct object_entry to indicate when an object\nhas already been written but to a previous pack.  The fields\nin object_entry are re-arranged & shrunk to save memory.\n\nSigned-off-by: Dana How <how@deathvalley.cswitch.com>\n---\n builtin-pack-objects.c |   21 ++++++++++++---------\n 1 files changed, 12 insertions(+), 9 deletions(-)\n\ndiff --git a/builtin-pack-objects.c b/builtin-pack-objects.c\nindex 45ac3e4..64318b3 100644\n--- a/builtin-pack-objects.c\n+++ b/builtin-pack-objects.c\n@@ -21,18 +21,15 @@ git-pack-objects [{ -q | --progress | --all-progress }] \\n\\\n \t[<ref-list | <object-list]\";\n \n struct object_entry {\n-\tunsigned char sha1[20];\n \tunsigned long size;\t/* uncompressed size */\n+\tunsigned long delta_size;\t/* delta data size (uncompressed) */\n+#define in_pack_header_size delta_size\t/* only when reusing pack data */\n \toff_t offset;\t/* offset into the final pack file;\n \t\t\t\t * nonzero if already written.\n \t\t\t\t */\n-\tunsigned int depth;\t/* delta depth */\n-\tunsigned int delta_limit;\t/* base adjustment for in-pack delta */\n \tunsigned int hash;\t/* name hint hash */\n-\tenum object_type type;\n-\tenum object_type in_pack_type;\t/* could be delta */\n-\tunsigned long delta_size;\t/* delta data size (uncompressed) */\n-#define in_pack_header_size delta_size\t/* only when reusing pack data */\n+\tunsigned short depth;\t/* delta depth */\n+\tunsigned short delta_limit;\t/* base adjustment for in-pack delta */\n \tstruct object_entry *delta;\t/* delta base object */\n \tstruct packed_git *in_pack; \t/* already in pack */\n \toff_t in_pack_offset;\n@@ -40,10 +37,14 @@ struct object_entry {\n \tstruct object_entry *delta_sibling; /* other deltified objects who\n \t\t\t\t\t     * uses the same base as me\n \t\t\t\t\t     */\n-\tint preferred_base;\t/* we do not pack this, but is encouraged to\n+\tenum object_type type;\n+\tenum object_type in_pack_type;\t/* could be delta */\n+\tchar preferred_base;\t/* we do not pack this, but is encouraged to\n \t\t\t\t * be used as the base objectto delta huge\n \t\t\t\t * objects against.\n \t\t\t\t */\n+\tchar prev_pack;\t\t/* written to previous pack? */\n+\tunsigned char sha1[20];\n };\n \n /*\n@@ -66,9 +67,11 @@ static int local;\n static int incremental;\n static int allow_ofs_delta;\n \n+static struct object_entry **written_list;\n static struct object_entry **sorted_by_sha, **sorted_by_type;\n static struct object_entry *objects;\n-static uint32_t nr_objects, nr_alloc, nr_result;\n+static uint32_t nr_objects, nr_alloc, nr_result, nr_written;\n+static uint32_t offset_limit;\n static const char *base_name;\n static unsigned char pack_file_sha1[20];\n static int progress = 1;\n-- \n1.5.1.89.g8abf0\n"},{"id":"38897","messageId":"7vabxi8lqv.fsf@assigned-by-dhcp.cox.net","threadId":"7570","inReplyTo":"46197885.3060502@gmail.com","subject":"Re: [PATCH 1/8] git-repack --max-pack-size: Add new file statics and struct fields","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-04-08T23:55:20Z","receivedAt":"2007-04-08T23:55:20Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Dana How <danahow@gmail.com> writes:\n\n> ... The fields\n> in object_entry are re-arranged & shrunk to save memory.\n\nIs the driving principle \"place fields with coarser alignment\nrequirements first in the struct\"?  I noticed you have a handful\npointers and an off_t after two short fields.  Two shorts would\nbe likely to make the next field aligned suitable for an int,\nbut (1) if we ever add another short later that would not be\ntrue anymore, and (2) I suspect a pointer and an off_t can be\nlonger than an int but int would never be longer than them.\n"},{"id":"38946","messageId":"56b7f5510704091138r166d6caer7ea4b2497889a4c0@mail.gmail.com","threadId":"7570","inReplyTo":"7vabxi8lqv.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH 1/8] git-repack --max-pack-size: Add new file statics and struct fields","fromName":"Dana How","fromEmail":"danahow@gmail.com","sentAt":"2007-04-09T18:38:34Z","receivedAt":"2007-04-09T18:38:34Z","isPatch":true,"sender":{"key":"danahow@gmail.com","avatar":null},"body":"On 4/8/07, Junio C Hamano <junkio@cox.net> wrote:\n> Dana How <danahow@gmail.com> writes:\n>\n> > ... The fields\n> > in object_entry are re-arranged & shrunk to save memory.\n>\n> Is the driving principle \"place fields with coarser alignment\n> requirements first in the struct\"?  I noticed you have a handful\n> pointers and an off_t after two short fields.  Two shorts would\n> be likely to make the next field aligned suitable for an int,\n> but (1) if we ever add another short later that would not be\n> true anymore, and (2) I suspect a pointer and an off_t can be\n> longer than an int but int would never be longer than them.\nAll true.  My objective was to save more memory than I had\n\"wasted\" by adding the prev_pack field.  Since it appears\nI'll be submitting the patchset yet again,  I'll make this\nre-arrangement complete next time.\n\nThanks,\n-- \nDana L. How  danahow@gmail.com  +1 650 804 5991 cell\n"}]}