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

Re: [PATCH v4] Threaded grep

From
Linus Torvalds <torvalds@linux-foundation.org>
Date
Jan 26, 2010, 16:56 UTC
Message-ID
<alpine.LFD.2.00.1001260846330.3574@localhost.localdomain>
In-Reply-To
<alpine.LFD.2.00.1001260836520.3574@localhost.localdomain>
On Tue, 26 Jan 2010, Linus Torvalds wrote:
Show 15 quoted lines
>
> Goodie.  It's noticeable for me. This is what I reported earlier:
> 
> > > $ /usr/bin/time git grep void
> > 
> > Before:
> > 
> >         real    0m1.144s
> > 
> > After:
> >         real    0m0.290s
> 
> and with your patch I get
> 
> 	real	0m0.239s

Btw, I have to also say that this whole performance reduction _feels_ good. It's very noticeable in normal use. "git grep" was always fast (it's been getting a bit slower as the kernel has grown, though), but it used to be still a noticeable pause.

Now it just -feels- very immediate. That quarter second is short enough that I can see the pause, but I don't feel it. It's like the results just "are there" rather than get searched for.

But perhaps even more importantly, it's also noticeable for me in the cold-cache case. IOW, after I do

	echo 3 > /proc/sys/vm/drop_caches
the threaded grep is able to do much better at reading the disk:
Before threading:
	[torvalds@nehalem linux]$ time git grep void > /dev/null 
	real	0m11.745s
	user	0m2.380s
	sys	0m1.200s
After:
	[torvalds@nehalem linux]$ time ~/git/git grep void > /dev/null 
	real	0m3.710s
	user	0m2.564s
	sys	0m2.076s

although it is worth noting that that machine has an Intel SSD, which is why it gets sped up so much by parallel IO (there's no seek penalty, and it is able to read multiple channels in parallel, so this gives much better IO patterns for it - with rotational media the numbers might be very different).

IOW, the whole threaded grep thing is a 4x performance improvement in hot-cache, and a 3x improvement in cold-cache.

Major good mojo.
		Linus
Previous: Linus TorvaldsNext: Mike Hommey
Message 7 of 12 in “Threaded grep”
  1. Threaded grepFredrik Kuivinen, Jan 25, 2010
  2. Linus TorvaldsJan 25, 2010
  3. Fredrik KuivinenJan 26, 2010
  4. Linus TorvaldsJan 26, 2010
  5. Benjamin KramerJan 26, 2010
  6. Linus TorvaldsJan 26, 2010
  7. Linus TorvaldsJan 26, 2010
  8. Mike HommeyJan 26, 2010
  9. grep: use REG_STARTEND (if available) to speed up regexecBenjamin Kramer, Jan 26, 2010
  10. Junio C HamanoJan 26, 2010
  11. Fredrik KuivinenJan 26, 2010
  12. Junio C HamanoJan 26, 2010

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.