summaryrefslogtreecommitdiff
path: root/grep.h
diff options
context:
space:
mode:
authorFredrik Kuivinen <frekui@gmail.com>2010-01-25 23:51:39 +0100
committerJunio C Hamano <gitster@pobox.com>2010-01-26 09:20:07 -0800
commit5b594f457afcf2cdddb3c79de8bcc571c775aa55 (patch)
treed3014dfa67180a040e0b542f7e46a1f38321158e /grep.h
parentc8610a2e7eca60a060f719f0aeb20f146e339de4 (diff)
downloadgit-5b594f457afcf2cdddb3c79de8bcc571c775aa55.tar.gz
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>
Diffstat (limited to 'grep.h')
-rw-r--r--grep.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/grep.h b/grep.h
index 0c61b00cbf..9703087996 100644
--- a/grep.h
+++ b/grep.h
@@ -91,6 +91,9 @@ struct grep_opt {
unsigned last_shown;
int show_hunk_mark;
void *priv;
+
+ void (*output)(struct grep_opt *opt, const void *data, size_t size);
+ void *output_priv;
};
extern void append_grep_pattern(struct grep_opt *opt, const char *pat, const char *origin, int no, enum grep_pat_token t);
@@ -99,4 +102,7 @@ extern void compile_grep_patterns(struct grep_opt *opt);
extern void free_grep_patterns(struct grep_opt *opt);
extern int grep_buffer(struct grep_opt *opt, const char *name, char *buf, unsigned long size);
+extern struct grep_opt *grep_opt_dup(const struct grep_opt *opt);
+extern int grep_threads_ok(const struct grep_opt *opt);
+
#endif