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

Re: [PATCH 1/3] pack-objects: fix tree_depth and layer invariants

From
Jeff King <peff@peff.net>
Date
Nov 22, 2018, 16:50 UTC
Message-ID
<20181122165012.GH28192@sigill.intra.peff.net>
In-Reply-To
<CACsJy8AETNxNnEq-8ROrQTkjy-_9mtoprmc=BQ554f7QECajPw@mail.gmail.com>
On Tue, Nov 20, 2018 at 05:37:18PM +0100, Duy Nguyen wrote:
Show 18 quoted lines
> > But in (b), we use the number of stored objects, _not_ the allocated
> > size of the objects array. So we can run into a situation like this:
> >
> >   1. packlist_alloc() needs to store the Nth object, so it grows the
> >      objects array to M, where M > N.
> >
> >   2. oe_set_tree_depth() wants to store a depth, so it allocates an
> >      array of length N. Now we've violated our invariant.
> >
> >   3. packlist_alloc() needs to store the N+1th object. But it _doesn't_
> >      grow the objects array, since N <= M still holds. We try to assign
> >      to tree_depth[N+1], which is out of bounds.
> 
> Do you think if this splitting data to packing_data is too fragile
> that we should just scrape the whole thing and move all data back to
> object_entry[]? We would use more memory of course but higher memory
> usage is still better than more bugs (if these are likely to show up
> again).
Certainly that thought crossed my mind while working on these patches. :)

Especially given the difficulties it introduced into the recent bitmap-reuse topic, and the size fixes we had to deal with in v2.19.

Overall, though, I dunno. This fix, while subtle, turned out not to be too complicated. And the memory savings are real. I consider 100M objects to be on the large size of feasible for stock Git these days, and I think we are talking about on the order of 4GB memory savings there. You need a big machine to handle a repository of that size, but 4GB is still appreciable.

So I guess at this point, with all (known) bugs fixed, we should stick with it for now. If it becomes a problem for development of a future feature, then we can re-evaluate then.

-Peff
Previous: Duy NguyenNext: Junio C Hamano
Message 4 of 9 in “delta-island fixes”
  1. 0/3 delta-island fixesJeff King, Nov 20, 2018
  2. 1/3 pack-objects: fix tree_depth and layer invariantsJeff King, Nov 20, 2018
  3. Duy NguyenNov 20, 2018
  4. Jeff KingNov 22, 2018
  5. Junio C HamanoNov 21, 2018
  6. 2/3 pack-objects: zero-initialize tree_depth/layer arraysJeff King, Nov 20, 2018
  7. 3/3 pack-objects: fix off-by-one in delta-island tree-depth computationJeff King, Nov 20, 2018
  8. Derrick StoleeNov 20, 2018
  9. Jeff KingNov 22, 2018

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.