git/list[1] front-page[2] threads[3] people[4] search[5] about
wed 2026-10-07 17:15 UTC

Re: grep vs git grep performance?

From
SZEDER Gábor <szeder.dev@gmail.com>
Date
Oct 26, 2017, 16:13 UTC
Message-ID
<20171026161354.23037-1-szeder.dev@gmail.com>
In-Reply-To
<1509030170.10651.59.camel@perches.com>
Show 18 quoted lines
> Comparing a cache warm git grep vs command line grep
> shows significant differences in cpu & wall clock.
> 
> Any ideas how to improve this?
> 
> $ time git grep "\bseq_.*%p\W" | wc -l
> 112
> 
> real	0m4.271s
> user	0m15.520s
> sys	0m0.395s
> 
> $ time grep -r --include=*.[ch] "\bseq_.*%p\W" * | wc -l
> 112
> 
> real	0m1.164s
> user	0m0.847s
> sys	0m0.314s

Note that this "regular" grep is limited to *.c and *.h files, while the above git grep invocation isn't and has to look at all tracked files. How does

  git grep "\bseq_.*%p\W" "*.[ch]"
fare?
Previous: Joe PerchesNext: Joe Perches
Message 4 of 12 in “grep vs git grep performance?”
  1. Joe PerchesOct 26, 2017
  2. Han-Wen NienhuysOct 26, 2017
  3. Joe PerchesOct 26, 2017
  4. SZEDER GáborOct 26, 2017
  5. Joe PerchesOct 26, 2017
  6. Stefan BellerOct 26, 2017
  7. Joe PerchesOct 26, 2017
  8. Stefan BellerOct 26, 2017
  9. Joe PerchesOct 27, 2017
  10. Ævar Arnfjörð BjarmasonOct 27, 2017
  11. Joe PerchesOct 27, 2017
  12. Ævar Arnfjörð BjarmasonOct 28, 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.