Threaded grep
authorFredrik Kuivinen <frekui@gmail.com>
Mon, 25 Jan 2010 22:51:39 +0000 (23:51 +0100)
committerJunio C Hamano <gitster@pobox.com>
Tue, 26 Jan 2010 17:20:07 +0000 (09:20 -0800)
commit5b594f457afcf2cdddb3c79de8bcc571c775aa55
treed3014dfa67180a040e0b542f7e46a1f38321158e
parentc8610a2e7eca60a060f719f0aeb20f146e339de4
Threaded grep

Make git grep use threads when it is available.

The results below are best of five runs in the Linux repository (on a
box with two cores).

With the patch:

git grep qwerty
1.58user 0.55system 0:01.16elapsed 183%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+800outputs (0major+5774minor)pagefaults 0swaps

Without:

git grep qwerty
1.59user 0.43system 0:02.02elapsed 100%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+800outputs (0major+3716minor)pagefaults 0swaps

And with a pattern with quite a few matches:

With the patch:

$ /usr/bin/time git grep void
5.61user 0.56system 0:03.44elapsed 179%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+800outputs (0major+5587minor)pagefaults 0swaps

Without:

$ /usr/bin/time git grep void
5.36user 0.51system 0:05.87elapsed 100%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+800outputs (0major+3693minor)pagefaults 0swaps

In either case we gain about 40% by the threading.

Signed-off-by: Fredrik Kuivinen <frekui@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-grep.c
grep.c
grep.h