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

Re: [PATCH v2 3/3] index-pack: eliminate unlimited recursion in get_delta_base()

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 9, 2012, 22:51 UTC
Message-ID
<7vvcokcwvt.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1326081546-29320-4-git-send-email-pclouds@gmail.com>
Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:
Show 6 quoted lines
> Revert the order of delta applying so that by the time a delta is
> applied, its base is either non-delta or already inflated.
>
> get_delta_base() is still recursive, but because base's data is always
> ready, the inner get_delta_base() call never has any chance to call
> itself again.

I suspect s/Revert/Reverse/ here, but I have a feeling that the structure of the resulting code is a bit too complex and subtle.

In parse_pack_objects(), we have two passes. The first pass scans to enumerate the objects that appear in the pack and sift them into base and delta objects, and the second one starts from a base object, resolves its immediate children with find_unresolved_daltas(), but that function recurses many times, bound only by the number of objects in the pack, which is the issue you are trying to address with this series.

I wonder if a cleaner approach is to change the loop in the second pass in such a way that (1) the function it calls resolves _only_ the immediate children of the object we know its final shape (either because the object was recorded in the deflated form in the pack, or we have already resolved it in earlier iteration), and (2) the loop goes over the objects[] array not just once, but until we stopped making progress.

It would require us to be able to tell, by looking at objects[i], if the object itself has already been handled (perhaps you can look at its idx.sha1 field for this purpose) and if we have already handled its immediate delta children (you may need to add a bit to struct object_entry for this).

Previous: Nguyễn Thái Ngọc DuyNext: Nguyen Thai Ngoc Duy
Message 19 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.