{"thread":{"id":"1066","subject":"[PATCH] pack-objects: emit base before delta.","startedAt":"2005-07-01T05:58:03Z","lastAt":"2005-07-01T15:40:12Z","messageCount":4,"participants":["Junio C Hamano","Linus Torvalds"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"5507","messageId":"7vbr5nxe38.fsf@assigned-by-dhcp.cox.net","threadId":"1066","inReplyTo":null,"subject":"[PATCH] pack-objects: emit base before delta.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-07-01T05:58:03Z","receivedAt":"2005-07-01T05:58:03Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"This micro-optimizes the order of objects in a pack.  By\nemitting base objects before deltified ones, unpack-objects do\nnot keep items on delta_list.\n\nI think it is prudent to keep the add_delta_to_list() logic in\nunpack-objects, so this commit only changes the packing side.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n---\n\n pack-objects.c |    8 +++++---\n 1 files changed, 5 insertions(+), 3 deletions(-)\n\n9be15981d7038f1d9d0b105f45760987584e60a6\ndiff --git a/pack-objects.c b/pack-objects.c\n--- a/pack-objects.c\n+++ b/pack-objects.c\n@@ -114,11 +114,13 @@ static unsigned long write_one(struct sh\n \t\t * if it is written already.\n \t\t */\n \t\treturn offset;\n-\te->offset = offset;\n-\toffset += write_object(f, e);\n-\t/* if we are delitified, write out its base object. */\n+\n+\t/* if we are delitified, write out its base objects first */\n \tif (e->delta)\n \t\toffset = write_one(f, e->delta, offset);\n+\n+\te->offset = offset;\n+\toffset += write_object(f, e);\n \treturn offset;\n }\n \n------------\n"},{"id":"5508","messageId":"7v64vvxd5x.fsf@assigned-by-dhcp.cox.net","threadId":"1066","inReplyTo":"7vbr5nxe38.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] pack-objects: emit base before delta.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-07-01T06:18:02Z","receivedAt":"2005-07-01T06:18:02Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":">>>>> \"JCH\" == Junio C Hamano <junkio@cox.net> writes:\n\nJCH> This micro-optimizes the order of objects in a pack.  By\nJCH> emitting base objects before deltified ones, unpack-objects do\nJCH> not keep items on delta_list.\n\nOops; \"does not have to keep items\" is what I meant.\n"},{"id":"5537","messageId":"Pine.LNX.4.58.0507010821140.14331@ppc970.osdl.org","threadId":"1066","inReplyTo":"7vbr5nxe38.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] pack-objects: emit base before delta.","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2005-07-01T15:28:07Z","receivedAt":"2005-07-01T15:28:07Z","isPatch":true,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Thu, 30 Jun 2005, Junio C Hamano wrote:\n>\n> This micro-optimizes the order of objects in a pack.  By\n> emitting base objects before deltified ones, unpack-objects do\n> not keep items on delta_list.\n\nSo I like this from an unpacking standpoint, but at the same time I don't \nactually think it's correct from an access pattern standpoint.\n\nWhen using a pack file as a run-time object store, the current packing \norder means that we generally traverse the pack-file in a nice forward \ndirection. We don't jump backwards in the file very much, which should be \ngood both for CPU and disk caches (both of them tend to have prefetch \nlogic that often works better for nice access patterns). So I was actually \npretty happy with the fact that we packed \"optimally\" in this sense: if \nthe object was an important delta (ie an early one), we'd basically end up \nalways walking forward until we hit the object it was a delta against.\n\nI dunno. Maybe it doesn't matter. Our other heuristics to pack recent \nobjects before later one might mean that we tend to have mainly \nbackwards-going deltas (both in history _and_ in pack file layout).\n\nThe expense of keeping track of delta objects isn't that high, and the \n\"pending delta\" logic in unpack-objects isn't that complicated, so ..\n\nDo you have some other reason you want to do this?\n\n\t\tLinus\n"},{"id":"5538","messageId":"7v1x6iilgj.fsf@assigned-by-dhcp.cox.net","threadId":"1066","inReplyTo":"Pine.LNX.4.58.0507010821140.14331@ppc970.osdl.org","subject":"Re: [PATCH] pack-objects: emit base before delta.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-07-01T15:40:12Z","receivedAt":"2005-07-01T15:40:12Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":">>>>> \"LT\" == Linus Torvalds <torvalds@osdl.org> writes:\n\nLT> So I like this from an unpacking standpoint, but at the same\nLT> time I don't actually think it's correct from an access\nLT> pattern standpoint.\n\nMy faulty logic, when I did the patch, was \"we would jump around\non random access anyway, so forcing the runtime to go backwards\neven when we know that these 40 objects are followed in this\nexact order to resolve delta is also OK.\"  It is not.\n\nPlease drop the patch.\n"}]}