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

Re: [PATCH] ref-filter: handle nested tags in --points-at option

From
Jeff King <peff@peff.net>
Date
Jul 2, 2023, 22:02 UTC
Message-ID
<20230702220243.GA1534980@coredump.intra.peff.net>
In-Reply-To
<20230702125611.GA1036686@coredump.intra.peff.net>
On Sun, Jul 02, 2023 at 08:56:11AM -0400, Jeff King wrote:
Show 5 quoted lines
> My biggest question would be whether this introduces any performance
> penalty for the more common cases (lightweight tags and single-level
> annotated tags). The answer is "no", I think; we are already paying the
> cost to parse every object to find out if it's a tag, and your new loop
> only does an extra parse if we see a tag-of-tag. Good.

Reading more carefully, I think this does actually change the performance a bit, because we end up parsing the pointed-to commits, as well. So here's before and after your patch running "git for-each-ref --points-at=HEAD" on linux.git (785 refs, all but 3 are tags):

  Benchmark 1: ./git.old for-each-ref --points-at=HEAD
    Time (mean ± σ):      11.4 ms ±   0.2 ms    [User: 6.5 ms, System: 4.9 ms]
    Range (min … max):    11.0 ms …  12.3 ms    239 runs
  
  Benchmark 2: ./git.new for-each-ref --points-at=HEAD
    Time (mean ± σ):      20.6 ms ±   0.5 ms    [User: 10.4 ms, System: 10.2 ms]
    Range (min … max):    19.8 ms …  22.7 ms    133 runs
  
  Summary
    './git.old for-each-ref --points-at=HEAD' ran
      1.80 ± 0.06 times faster than './git.new for-each-ref --points-at=HEAD'

The absolute numbers are pretty small, but the percent change isn't great. I'll send some patches in a minute that can be applied on top to improve this case, as well as fix the other issues I pointed out in the existing code.

-Peff
Previous: Jeff KingNext: Jeff King
Message 5 of 15 in “ref-filter: handle nested tags in --points-at option”
  1. ref-filter: handle nested tags in --points-at optionJan Klötzke, Jul 1, 2023
  2. Jeff KingJul 2, 2023
  3. René ScharfeJul 2, 2023
  4. Jeff KingJul 2, 2023
  5. Jeff KingJul 2, 2023
  6. 0/3 a few --points-at optimizations/cleanupsJeff King, Jul 2, 2023
  7. 1/3 ref-filter: avoid parsing tagged objects in match_points_at()Jeff King, Jul 2, 2023
  8. 2/3 ref-filter: avoid parsing non-tags in match_points_at()Jeff King, Jul 2, 2023
  9. 3/3 ref-filter: simplify return type of match_points_atJeff King, Jul 2, 2023
  10. Jan KlötzkeJul 3, 2023
  11. Junio C HamanoJul 5, 2023
  12. Jeff KingJul 5, 2023
  13. Junio C HamanoJul 5, 2023
  14. Jan KlötzkeJul 5, 2023
  15. Junio C HamanoJul 5, 2023

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.