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

Re: [PATCH] check_refname_component: Optimize

From
Jeff King <peff@peff.net>
Date
May 30, 2014, 17:29 UTC
Message-ID
<20140530172944.GC25443@sigill.intra.peff.net>
In-Reply-To
<538853B5.1080308@alum.mit.edu>
On Fri, May 30, 2014 at 11:47:33AM +0200, Michael Haggerty wrote:
Show 12 quoted lines
> > I could guess something like "the writer has a different idea of what a
> > valid refname is than we do". But that applies as well to (2), but just
> > as "the reader who wrote packed-refs.stat has a different idea than we
> > do".
> 
> If we want to be robust to future changes to refname rules, we could add
> a header flag like
> 
>     # pack-refs with: peeled fully-peeled check-level=1.0
> 
> which promises that the reference names in the file conform to the
> current ("version 1.0") check_refname_format() rules.

Yeah, I thought about mentioning something like that. But really, this just seems like a lot of complexity to solve the problem in a wrong way.

It's not running check_refname_format that is the real problem. It's the fact that we do O(# of refs) work whenever we have to access the packed-refs file. check_refname_format is part of that, surely, but so is reading the file, creating all of the refname structs in memory, etc.

I'd much rather see a solution that lets us do O(log N) or O(1) work to access a ref, and then we don't have to care about optimizing check_refname_format specifically.

I don't mind internal code speedups to micro-optimize check_refname_format. They may make the code uglier, but they're fairly contained. But things like check-level are much more invasive, and we'll need to keep compatibility with them in future versions.

-Peff
Previous: Michael HaggertyNext: Michael Haggerty
Message 13 of 15 in “check_refname_component: Optimize”
  1. 0/1 check_refname_component: OptimizeDavid Turner, May 28, 2014
  2. check_refname_component: OptimizeDavid Turner, May 28, 2014
  3. Michael HaggertyMay 28, 2014
  4. David TurnerMay 28, 2014
  5. Duy NguyenMay 29, 2014
  6. Junio C HamanoMay 29, 2014
  7. Duy NguyenMay 29, 2014
  8. Jeff KingMay 29, 2014
  9. Duy NguyenMay 29, 2014
  10. Jeff KingMay 30, 2014
  11. Duy NguyenMay 30, 2014
  12. Michael HaggertyMay 30, 2014
  13. Jeff KingMay 30, 2014
  14. Michael HaggertyMay 31, 2014
  15. Duy NguyenMay 31, 2014

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.