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

Re: [PATCH 1/2] sha1_file: drop experimental GIT_USE_LOOKUP search

From
Jeff King <peff@peff.net>
Date
Aug 9, 2017, 21:09 UTC
Message-ID
<20170809210946.2pzz5rze4u57c4lr@sigill.intra.peff.net>
In-Reply-To
<xmqqshh06264.fsf@gitster.mtv.corp.google.com>
On Wed, Aug 09, 2017 at 11:12:19AM -0700, Junio C Hamano wrote:
> Thanks for reducing the count of binary search functions by one.
> 
> I think the "just one round of newton-raphson" in sha1_pos() comes
> from [*1*]; I agree that it needs benchmarking before tweaking it.

Actually, it's weirder than that. You mentioned it in that thread, but the code dates back much further. It was moved to the file in 96beef8, but that was just a copy from patch-ids.c. The original seems to be from 5d23e133d2 (Refactor patch-id filtering out of git-cherry and git-format-patch., 2007-04-09), which predates the sha1_entry_pos() experiment.

I always thought those two sha1-lookup functions came in the opposite order, but I guess was wrong. Or possibly you are a time traveler.

> We may want to tell libgit2 folks about this change, though [*2*].
> I think they too are carrying dead code that is only used under CPP
> macro GIT_USE_LOOKUP, which they do not seem to define.

Good thinking. It looks like they could use all three of the patches under discussion. I opened some PRs:

  https://github.com/libgit2/libgit2/pull/4326
  https://github.com/libgit2/libgit2/pull/4327
  https://github.com/libgit2/libgit2/pull/4328
-Peff
Previous: Junio C HamanoNext: Jeff King
Message 11 of 14 in “sha1_file: avoid comparison if no packed hash matches the first byte”
  1. sha1_file: avoid comparison if no packed hash matches the first byteRené Scharfe, Aug 8, 2017
  2. Jonathan NiederAug 8, 2017
  3. Junio C HamanoAug 8, 2017
  4. Jeff KingAug 8, 2017
  5. Jeff KingAug 8, 2017
  6. Junio C HamanoAug 9, 2017
  7. Jeff KingAug 9, 2017
  8. Jeff KingAug 9, 2017
  9. 1/2 sha1_file: drop experimental GIT_USE_LOOKUP searchJeff King, Aug 9, 2017
  10. Junio C HamanoAug 9, 2017
  11. Jeff KingAug 9, 2017
  12. 2/2 hashcmp: use memcmp instead of open-coded loopJeff King, Aug 9, 2017
  13. René ScharfeAug 9, 2017
  14. Jeff KingAug 9, 2017

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.