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

Re: [RFC 5/5] Support 'master@2 hours ago' syntax

From
Shawn Pearce <spearce@spearce.org>
Date
May 17, 2006, 22:32 UTC
Message-ID
<20060517223246.GD30313@spearce.org>
In-Reply-To
<20060517220613.GC30313@spearce.org>
Shawn Pearce <spearce@spearce.org> wrote:
Show 16 quoted lines
> Junio C Hamano <junkio@cox.net> wrote:
> >
> > Also I wonder how much complexity would we suffer and how much
> > efficiency would we gain if we binary search the logdata (the
> > committer info is variable length, so you would need to resync
> > in each step).
> 
> I thought about doing this but did not think it would be worth the
> effort (either developer to code or CPU to execute) at this point
> in time.  I don't think users will be pulling refs from the log very
> often and if they are they will probably be pulling from recent time,
> not very far back.  Thus starting at the end and walking back is
> probably "good enough".
> 
> But if it proves to be too slow in practice I'm sure I can come up
> with a faster way to walk through the log.  :-)

I just ran a test on my PowerBook: walking a 10,000 line log file and extracting the very oldest commit along. Each hit on git-rev-parse seems to took about 100 ms. Hardly worth worrying about for casual use. Further git-rev-parse is taking 73 ms just to run '--verify HEAD' so an extra 30 ms to read the 10k log is pretty much nothing.

  [spearce@pb15 trash]$ wc -l .git/logs/refs/heads/master 
     10000 .git/logs/refs/heads/master
  [spearce@pb15 trash]$ head -n 1 .git/logs/refs/heads/master 
  b943559a305bdd6bdee2cef6e5df2413c3d30a00 0000000000000000000000000000000000000000 A U Thor <example@example.com> 1136091600 -0500
  [spearce@pb15 trash]$ perl -e 'print scalar(localtime shift),"\n"' 1136091600
  Sun Jan  1 00:00:00 2006
  [spearce@pb15 trash]$ time ../../git-rev-parse --verify HEAD@'300 days'
  warning: Log .git/logs/refs/heads/master only goes back to Thu, 1 Jan 1970 00:00:00 +0000.
  b943559a305bdd6bdee2cef6e5df2413c3d30a00
  
  real    0m0.112s
  user    0m0.029s
  sys     0m0.023s
  [spearce@pb15 trash]$ time ../../git-rev-parse --verify HEAD@'300 days'
  warning: Log .git/logs/refs/heads/master only goes back to Thu, 1 Jan 1970 00:00:00 +0000.
  b943559a305bdd6bdee2cef6e5df2413c3d30a00
  
  real    0m0.105s
  user    0m0.029s
  sys     0m0.023s
-- 
Shawn.
Previous: Shawn Pearce
Message 7 of 7 in “[RFC 5/5] Support 'master@2 hours ago' syntax”
  1. Shawn PearceMay 17, 2006
  2. Junio C HamanoMay 17, 2006
  3. Linus TorvaldsMay 17, 2006
  4. Junio C HamanoMay 17, 2006
  5. Shawn PearceMay 17, 2006
  6. Shawn PearceMay 17, 2006
  7. Shawn PearceMay 17, 2006

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.