Re: [PATCH v2 3/3] grep: disable threading in all but worktree case
- From
René Scharfe <rene.scharfe@lsrfire.ath.cx>
- Date
- Dec 7, 2011, 16:52 UTC
- Message-ID
- <4EDF99BA.3040006@lsrfire.ath.cx>
- In-Reply-To
- <20111207042431.GA10765@sigill.intra.peff.net>
Am 07.12.2011 05:24, schrieb Jeff King:
Show 17 quoted lines
> On Tue, Dec 06, 2011 at 11:48:26PM +0100, René Scharfe wrote:
>
>> #ifndef NO_PTHREADS
>> - if (use_threads) {
>> + if (nr_threads > 0) {
>> grep_sha1_async(opt, name, sha1);
>> return 0;
>> } else
>
> Should this be "if (nr_threads > 1)"?
>
> As a user, I would do:
>
> git grep --threads=1 ...
>
> if I wanted a single-threaded process. Instead, we actually spawn a
> sub-thread and do all of the locking, which has a measurable cost:Yes, the difference is measurable, and that's exactly how I like it to be. :) A user can turn off threading with --threads=0 or (more intuitively) --no-threads. And we can quantify the overhead.
Show 11 quoted lines
> $ time git grep --threads=0 SIMPLE HEAD >/dev/null > real 0m2.994s > user 0m2.932s > sys 0m0.060s > > $ time git grep --threads=1 SIMPLE HEAD >/dev/null > real 0m3.407s > user 0m3.392s > sys 0m0.140s > > Should --threads=1 be equivalent to --threads=0?
We can do that if there's another way to calculate this difference, or if it is not useful to know. I find your results interesting at least, though. :)
René