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

Re: [PATCH v2 2/3] index-pack: eliminate recursion in find_unresolved_deltas

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 12, 2012, 20:32 UTC
Message-ID
<7vipkg1x1w.fsf@alter.siamese.dyndns.org>
In-Reply-To
<CACsJy8Cz-qWs2wrOYTjDMPjJH0wRQCFy9u6OFVPzn6YV0a6WaQ@mail.gmail.com>
Nguyen Thai Ngoc Duy <pclouds@gmail.com> writes:
Show 28 quoted lines
> 2012/1/10 Junio C Hamano <gitster@pobox.com>:
>> Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:
>>
>>> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
>>
>> I find both the original and the updated code rather dense to read without
>> annotation, but from a cursory look all changes look good.
>
> Maybe I stared at it for too long it seems obvious to me (hence no
> further description in commit message). Let me describe it (and put in
> commit message later if it makes sense)
>
> Current code already links all bases together in a form of tree, using
> struct base_data, with prev_base pointer to point to parent node. The
> only problem is that struct base_data is all allocated on stack. So we
> need to put all on heap (parse_pack_objects and
> fix_unresolved_deltas). After that, it's simple depth-first traversal
> where each node also maintains its own state (ofs and ref indices to
> iterate over all children nodes).
>
> So we process one node:
>
>  - if it returns a new (child) node (a parent base), we link it to our
> tree, then process the new node.
>  - if it returns nothing, the node is done, free it. We go back to
> parent node and resume whatever it's doing.
>
> and do it until we have no nodes to process.

If you have the current path (base to another that is recorded as a delta to it to yet another that is recorded as a delta to that delitified object) on the stack, it is obvious that as you have done with the objects on the deeper end of the delta chain, the data that becomes unnecessary will be gone by simply returning from the recursion, but if you "put all on heap", you would have to do the same freeing as part of the hand-rolled recursion. It is unclear if, where and how the patch takes care of that in the above.

Other than that, I find the description very readable.
Thanks.
Previous: Nguyen Thai Ngoc DuyNext: Nguyễn Thái Ngọc Duy
Message 17 of 21 in “Eliminate recursion in setting/clearing marks in commit list”
  1. 1/3 Eliminate recursion in setting/clearing marks in commit listNguyễn Thái Ngọc Duy, Dec 26, 2011
  2. 2/3 index-pack: eliminate recursion in find_unresolved_deltasNguyễn Thái Ngọc Duy, Dec 26, 2011
  3. 3/3 index-pack: eliminate unlimited recursion in get_delta_base()Nguyễn Thái Ngọc Duy, Dec 26, 2011
  4. 0/3 nd/index-pack-no-recurseNguyễn Thái Ngọc Duy, Jan 9, 2012
  5. Junio C HamanoJan 9, 2012
  6. 0/3 nd/index-pack-no-recurseNguyễn Thái Ngọc Duy, Jan 14, 2012
  7. 1/3 Eliminate recursion in setting/clearing marks in commit listNguyễn Thái Ngọc Duy, Jan 14, 2012
  8. Peter BaumannJan 14, 2012
  9. Nguyen Thai Ngoc DuyJan 15, 2012
  10. 2/3 index-pack: eliminate recursion in find_unresolved_deltasNguyễn Thái Ngọc Duy, Jan 14, 2012
  11. 3/3 index-pack: eliminate unlimited recursion in get_base_data()Nguyễn Thái Ngọc Duy, Jan 14, 2012
  12. 1/3 Eliminate recursion in setting/clearing marks in commit listNguyễn Thái Ngọc Duy, Jan 9, 2012
  13. Junio C HamanoJan 9, 2012
  14. 2/3 index-pack: eliminate recursion in find_unresolved_deltasNguyễn Thái Ngọc Duy, Jan 9, 2012
  15. Junio C HamanoJan 9, 2012
  16. Nguyen Thai Ngoc DuyJan 10, 2012
  17. Junio C HamanoJan 12, 2012
  18. 3/3 index-pack: eliminate unlimited recursion in get_delta_base()Nguyễn Thái Ngọc Duy, Jan 9, 2012
  19. Junio C HamanoJan 9, 2012
  20. Nguyen Thai Ngoc DuyJan 10, 2012
  21. Nguyen Thai Ngoc DuyJan 10, 2012

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.