git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: Jeff King <peff@peff.net>
Cc: "Git Mailing List" <git@vger.kernel.org>,
	"Junio C Hamano" <gitster@pobox.com>,
	"Jeffrey Walton" <noloader@gmail.com>,
	"Michał Kiedrowicz" <michal.kiedrowicz@gmail.com>,
	"J Smith" <dark.panda@gmail.com>,
	"Victor Leschuk" <vleschuk@gmail.com>,
	"Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>,
	"Thomas Rast" <trast@student.ethz.ch>,
	"Fredrik Kuivinen" <frekui@gmail.com>
Subject: Re: [PATCH 01/12] grep: add ability to disable threading with --threads=0 or grep.threads=0
Date: Tue, 11 Apr 2017 22:20:59 +0200	[thread overview]
Message-ID: <CACBZZX7vEQ5jUzX3GsD6JXe50TnRUtGmSVi7zBxwOmAQGABQ4Q@mail.gmail.com> (raw)
In-Reply-To: <20170411100656.5bptxdaptc4zznan@sigill.intra.peff.net>

On Tue, Apr 11, 2017 at 12:06 PM, Jeff King <peff@peff.net> wrote:
> On Sat, Apr 08, 2017 at 01:24:55PM +0000, Ævar Arnfjörð Bjarmason wrote:
>
>> Add the ability to entirely disable threading by having grep.threads=0
>> in the config or --threads=0 on the command-line.
>
> In pack-objects and index-pack, --threads=0 means "auto-detect". It
> seems like we should try to keep this consistent.
>
> Wouldn't --threads=1 be a better way to disable threading? Pack-objects
> is smart enough to just use the non-threaded code path entirely in that
> case (rather than wasting time spawning a single worker thread). Grep
> should probably do the same.

I'm struggling to find a use-case where threading makes sense at all.
The example in the initial introduction in 5b594f457a is always slower
with >0 for me, and since then in 0579f91dd7 it got disabled entirely
for non-worktree cases.

But assuming it works for someone out there, then 0 threads is clearly
not the same as 1. On linux.git with pcre2 grepping for [q]werty for
example[1]

        Rate P_12  P_8  P_4  P_1  P_2  P_0
P_12 0.861/s   --  -7% -22% -27% -30% -43%
P_8  0.924/s   7%   -- -16% -22% -25% -39%
P_4   1.10/s  28%  19%   --  -7% -10% -27%
P_1   1.19/s  38%  29%   8%   --  -3% -21%
P_2   1.23/s  43%  33%  12%   4%   -- -18%
P_0   1.51/s  75%  63%  37%  27%  22%   --

And for [a]var on git.git:

       Rate P_12  P_8  P_4  P_2  P_1  P_0
P_12 15.6/s   --  -5% -15% -17% -21% -42%
P_8  16.4/s   5%   -- -11% -12% -17% -39%
P_4  18.4/s  18%  13%   --  -1%  -7% -32%
P_2  18.7/s  20%  14%   1%   --  -6% -31%
P_1  19.8/s  27%  21%   8%   6%   -- -27%
P_0  27.0/s  73%  65%  46%  44%  36%   --

Tthere's a >20% performance difference between 0 and 1 threads. The
more threads I add the slower it gets, but if there's some case where
we have the inverse of that and you have e.g. 2 cores, then presumably
you really want 1 thread, and not 0, or 2.

>> +static int thread_callback(const struct option *opt,
>> +                        const char *arg, int unset)
>> +{
>> +     int *threads = (int*)opt->value;
>> +     char *end;
>> +
>> +     if (unset) {
>> +             *threads = GREP_NUM_THREADS_DEFAULT;
>> +             return 0;
>> +     }
>
> This means that "--no-threads" will use 8 threads. Which _kind of_ makes
> sense in that it cancels any previous "--threads", but I wonder if it
> should be the same as "--threads=1".

Dear lazyweb, how do you distinguish --no-foo from no --foo=X being
provided in this API?

> This isn't really a change in behavior from the existing code, though
> (OPT_INTEGER will set it to 0 in that case, too, and we'd later pick up
> the default value).

1. =~/g/git/ perl -MBenchmark=cmpthese -wE 'cmpthese(10, { map { my $t
= $_; +("P_$t" => sub { system "$ENV{PF}git -c grep.patternType=pcre2
grep --threads=$t [q]werty >/dev/null" }) } 0,1,2,4,8,12 })'

  reply	other threads:[~2017-04-11 20:21 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-08 13:24 [PATCH 00/12] PCREv2 & more Ævar Arnfjörð Bjarmason
2017-04-08 13:24 ` [PATCH 01/12] grep: add ability to disable threading with --threads=0 or grep.threads=0 Ævar Arnfjörð Bjarmason
2017-04-11 10:06   ` Jeff King
2017-04-11 20:20     ` Ævar Arnfjörð Bjarmason [this message]
2017-04-11 20:34       ` Jeff King
2017-04-11 20:56         ` Ævar Arnfjörð Bjarmason
2017-04-14 21:23           ` Jeff King
2017-04-16 22:25             ` Ævar Arnfjörð Bjarmason
2017-04-08 13:24 ` [PATCH 02/12] grep: remove redundant regflags assignment under PCRE Ævar Arnfjörð Bjarmason
2017-04-11 10:10   ` Jeff King
2017-04-08 13:24 ` [PATCH 03/12] Makefile & configure: reword outdated comment about PCRE Ævar Arnfjörð Bjarmason
2017-04-11 10:14   ` Jeff King
2017-04-15 12:10     ` Ævar Arnfjörð Bjarmason
2017-04-08 13:24 ` [PATCH 04/12] grep: add a test for backreferences in PCRE patterns Ævar Arnfjörð Bjarmason
2017-04-08 13:24 ` [PATCH 05/12] log: add exhaustive tests for pattern style options & config Ævar Arnfjörð Bjarmason
2017-04-11 10:23   ` Jeff King
2017-04-11 10:32     ` Ævar Arnfjörð Bjarmason
2017-04-11 10:51       ` Jeff King
2017-04-08 13:25 ` [PATCH 06/12] log: add -P as a synonym for --perl-regexp Ævar Arnfjörð Bjarmason
2017-04-10  2:39   ` Junio C Hamano
2017-04-11 10:26   ` Jeff King
2017-04-08 13:25 ` [PATCH 07/12] grep & rev-list doc: stop promising libpcre " Ævar Arnfjörð Bjarmason
2017-04-08 13:25 ` [PATCH 08/12] grep: make grep.patternType=[pcre|pcre1] a synonym for "perl" Ævar Arnfjörð Bjarmason
2017-04-11 10:30   ` Jeff King
2017-04-08 13:25 ` [PATCH 09/12] test-lib: rename the LIBPCRE prerequisite to PCRE Ævar Arnfjörð Bjarmason
2017-04-11 10:31   ` Jeff King
2017-04-08 13:25 ` [PATCH 10/12] grep: change the internal PCRE macro names to be PCRE1 Ævar Arnfjörð Bjarmason
2017-04-11 10:35   ` Jeff King
2017-04-11 10:51     ` Ævar Arnfjörð Bjarmason
2017-04-11 10:53       ` Jeff King
2017-04-08 13:25 ` [PATCH 11/12] grep: change the internal PCRE code & header " Ævar Arnfjörð Bjarmason
2017-04-11 10:37   ` Jeff King
2017-04-11 10:45     ` Ævar Arnfjörð Bjarmason
2017-04-11 10:48       ` Jeff King
2017-04-11 11:02         ` Ævar Arnfjörð Bjarmason
2017-04-11 12:57           ` Jeff King
2017-04-11 16:51             ` Brandon Williams
2017-04-11 18:31               ` Ævar Arnfjörð Bjarmason
2017-04-08 13:25 ` [PATCH 12/12] grep: add support for PCRE v2 Ævar Arnfjörð Bjarmason
2017-04-11 10:43   ` Jeff King
2017-04-11 10:47 ` [PATCH 00/12] PCREv2 & more Jeff King
2017-04-15  8:11   ` Junio C Hamano
2017-04-15  9:50     ` Ævar Arnfjörð Bjarmason

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CACBZZX7vEQ5jUzX3GsD6JXe50TnRUtGmSVi7zBxwOmAQGABQ4Q@mail.gmail.com \
    --to=avarab@gmail.com \
    --cc=dark.panda@gmail.com \
    --cc=frekui@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=michal.kiedrowicz@gmail.com \
    --cc=noloader@gmail.com \
    --cc=pclouds@gmail.com \
    --cc=peff@peff.net \
    --cc=trast@student.ethz.ch \
    --cc=vleschuk@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).