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

Re: [PATCH 2/2] log: do not shorten decoration names too early

From
Junio C Hamano <gitster@pobox.com>
Date
May 14, 2015, 18:01 UTC
Message-ID
<xmqqzj576nts.fsf@gitster.dls.corp.google.com>
In-Reply-To
<20150514174945.GB7966@peff.net>
Jeff King <peff@peff.net> writes:
Show 8 quoted lines
> On Thu, May 14, 2015 at 10:37:39AM -0700, Junio C Hamano wrote:
> ...
>> Wouldn't the hashtable used by decorate.[ch] with the max load
>> factor capped to 66% a better economy?
>
> Good point. A slab would be less memory efficient, but cheaper to look
> up (it is a direct memory reference, with no probing and no hashcmp()).
> But cache effects matter, so it could even be slower.

Yes, that was what I meant by economy. I do not think memory footprint is free in that sense.

Show 9 quoted lines
> On the other hand, the slab makes it easy to actually store the real
> type (struct name_decoration), whereas the decorate hash stores only
> pointers. So we'd save an extra malloc/pointer in each case.
>
> So with your slab_peek() below, I'd guess that the slab would actually
> be faster. But I'd also be unsurprised if it makes no appreciable
> difference to the overall runtime of "git log --decorate". I think we'd
> have to build it and profile (and please feel free to say "eh, not worth
> the time to think about further").

While I think *slabname##_peek() would be worth doing regardless of this caller, I suspect that the major overhead of decorate code would come from the for_each_ref() that jumps deep into the history to parse old commits; it would trigger a lot of unpacking of objects deep in the delta chain, which would be expensive than table look-up in either scheme.

Show 9 quoted lines
>> I notice that there is no API into commit_slab to ask "Does this
>> commit have data in the slab?"  *slabname##_at() may be the closest
>> thing, but that would allocate the space and then says "This is the
>> slot for that commit; go check if there is data there already."
>
> Yes. I think it's not a big deal if your slab is reasonably full (you'll
> extend it to the full size of your commit space eventually either way).
> But for a sparse slab, it does make that query much more expensive than
> it needs to be.
Yes, and I think that commit decoration is such a use case.
Previous: Jeff KingNext: Jeff King
Message 10 of 17 in “"HEAD -> branch" decoration doesn't work with "--decorate=full"”
  1. Michael HaggertyMay 13, 2015
  2. Junio C HamanoMay 13, 2015
  3. Michael J GruberMay 13, 2015
  4. Junio C HamanoMay 13, 2015
  5. Junio C HamanoMay 13, 2015
  6. 2/2 log: do not shorten decoration names too earlyJunio C Hamano, May 13, 2015
  7. Jeff KingMay 14, 2015
  8. Junio C HamanoMay 14, 2015
  9. Jeff KingMay 14, 2015
  10. Junio C HamanoMay 14, 2015
  11. Jeff KingMay 14, 2015
  12. Junio C HamanoMay 14, 2015
  13. Jeff KingMay 14, 2015
  14. Junio C HamanoMay 14, 2015
  15. Jeff KingMay 14, 2015
  16. Junio C HamanoMay 22, 2015
  17. Jeff KingMay 22, 2015

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.