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

Re: [PATCH 0/5] tree-walk object_id refactor

From
brian m. carlson <sandals@crustytoothpaste.net>
Date
Jan 11, 2019, 00:17 UTC
Message-ID
<20190111001750.GO423984@genre.crustytoothpaste.net>
In-Reply-To
<20190110064030.GB20497@sigill.intra.peff.net>
On Thu, Jan 10, 2019 at 01:40:31AM -0500, Jeff King wrote:
Show 21 quoted lines
> On Thu, Jan 10, 2019 at 04:25:46AM +0000, brian m. carlson wrote:
> 
> > There are a small number of places in our codebase where we cast a
> > buffer of unsigned char to a struct object_id pointer. When we have
> > GIT_MAX_RAWSZ set to 32 (because we have SHA-256), one of these places
> > (the buffer for tree objects) can lead to us copying too much data when
> > using SHA-1 as the hash, since there are only 20 bytes to read.
> > 
> > This was not expected to be a problem before future code was introduced,
> > but due to a combination of series the issue became noticeable.
> > 
> > This series introduces a refactor to avoid referencing the struct
> > object_id directly from a buffer and instead storing an additional
> > struct object_id (and an int) in struct name_entry and referring to
> > that.
> 
> I think this is really the only safe and sane solution. We resisted it
> because of the cost of the extra copies (especially the
> update_tree_entry() one). But I don't know that anybody actually
> measured it. Do you have any performance numbers before/after this
> series?

Unfortunately, I don't. I'm not really sure in what situations we hit this code path a lot, so I'm not sure what exactly we should performance test. If you have suggestions, I can set up some perf tests.

I will say that I resisted writing this series for a long time, since I knew it was going to be a difficult slog to get everything working (and it was). If there had been a way to avoid it, I would have done it. However, writing this series led to about ten tests in my SHA-256 work suddenly passing where they hadn't before.

-- 
brian m. carlson: Houston, Texas, US
OpenPGP: https://keybase.io/bk2204
Previous: Jeff KingNext: Jeff King
Message 29 of 41 in “What's cooking in git.git (Jan 2019, #01; Mon, 7)”
  1. Junio C HamanoJan 7, 2019
  2. tg/checkout-no-overlay, was Re: What's cooking in git.git (Jan 2019, #01; Mon, 7)Thomas Gummerer, Jan 8, 2019
  3. Junio C HamanoJan 8, 2019
  4. ag/sequencer-reduce-rewriting-todo Re: What's cooking in git.git (Jan 2019, #01; Mon, 7)Alban Gruin, Jan 8, 2019
  5. sb/more-repo-in-api, was Re: What's cooking in git.git (Jan 2019, #01; Mon, 7)Jonathan Tan, Jan 8, 2019
  6. Junio C HamanoJan 8, 2019
  7. Stefan BellerJan 9, 2019
  8. Martin ÅgrenJan 9, 2019
  9. Martin ÅgrenJan 9, 2019
  10. brian m. carlsonJan 10, 2019
  11. Junio C HamanoJan 10, 2019
  12. Martin ÅgrenJan 10, 2019
  13. 0/5 tree-walk object_id refactorbrian m. carlson, Jan 10, 2019
  14. 1/5 tree-walk: copy object ID before usebrian m. carlson, Jan 10, 2019
  15. 2/5 match-trees: compute buffer offset correctly when splicingbrian m. carlson, Jan 10, 2019
  16. 3/5 match-trees: use hashcpy to splice treesbrian m. carlson, Jan 10, 2019
  17. Jeff KingJan 10, 2019
  18. brian m. carlsonJan 10, 2019
  19. Jeff KingJan 11, 2019
  20. Jeff KingJan 11, 2019
  21. brian m. carlsonJan 14, 2019
  22. Jeff KingJan 14, 2019
  23. 4/5 tree-walk: store object_id in a separate memberbrian m. carlson, Jan 10, 2019
  24. Jeff KingJan 10, 2019
  25. brian m. carlsonJan 10, 2019
  26. 5/5 cache: make oidcpy always copy GIT_MAX_RAWSZ bytesbrian m. carlson, Jan 10, 2019
  27. Jeff KingJan 10, 2019
  28. Jeff KingJan 10, 2019
  29. brian m. carlsonJan 11, 2019
  30. Jeff KingJan 11, 2019
  31. 0/5 tree-walk object_id refactorbrian m. carlson, Jan 15, 2019
  32. 1/5 tree-walk: copy object ID before usebrian m. carlson, Jan 15, 2019
  33. 2/5 match-trees: compute buffer offset correctly when splicingbrian m. carlson, Jan 15, 2019
  34. 4/5 tree-walk: store object_id in a separate memberbrian m. carlson, Jan 15, 2019
  35. 5/5 cache: make oidcpy always copy GIT_MAX_RAWSZ bytesbrian m. carlson, Jan 15, 2019
  36. 3/5 match-trees: use hashcpy to splice treesbrian m. carlson, Jan 15, 2019
  37. Junio C HamanoJan 15, 2019
  38. Jeff KingJan 9, 2019
  39. Junio C HamanoJan 10, 2019
  40. Junio C HamanoJan 10, 2019
  41. Stefan BellerJan 10, 2019

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.