From: John Keeping <john@keeping.me.uk>
To: Victor Leschuk <vleschuk@accesssoftek.com>
Cc: Victor Leschuk <vleschuk@gmail.com>,
"git@vger.kernel.org" <git@vger.kernel.org>
Subject: Re: [PATCH v3] Add git-grep threads param
Date: Tue, 27 Oct 2015 14:11:00 +0000 [thread overview]
Message-ID: <20151027141100.GR19802@serenity.lan> (raw)
In-Reply-To: <6AE1604EE3EC5F4296C096518C6B77EE5D0FDAB9FF@mail.accesssoftek.com>
On Tue, Oct 27, 2015 at 06:54:16AM -0700, Victor Leschuk wrote:
> Hello John,
>
> >> This thought also crossed my mind, however we already pass grep_opt to
> >> start_threads() function, so I think passing it to wait_all() is not
> >> that ugly, and kind of symmetric. And I do not like the idea of
> >> duplicating same information in different places. What do you think?
>
> > The grep_opt in start_threads() is being passed through to run(), so it
> > seems slightly different to me. If the threads were being setup in
> > grep.c (as opposed to builtin/grep.c) then I'd agree that it belongs in
> > grep_opt, but since this is local to this particular user of the grep
> > infrastructure adding num_threads to the grep_opt structure at all feels
> > wrong to me.
>
> > Note that I wasn't suggesting passing num_threads as a parameter to
> > wait_all(), but rather having it as global state that is accessed by
> > wait_all() in the same way as the `threads` array.
>
> > If we rename use_threads to num_threads and just use that, then we only
> > have the information in one place don't we?
>
> Yeah, I understood your idea. So we parse config_value directly to
>
> static int num_threads; /* old use_threads */
Presumably this is:
static int num_threads = -1;
so that the default behaviour continues to work correctly.
> And use it internally in builtin/grep.c. I think you are right.
>
> Looks like grep_cmd_config() is the right place to parse it. Something like:
>
> --- a/builtin/grep.c
> +++ b/builtin/grep.c
> @@ -267,6 +267,8 @@ static int wait_all(struct grep_opt *opt)
> static int grep_cmd_config(const char *var, const char *value, void *cb)
> {
> int st = grep_config(var, value, cb);
> + if (thread_config(var, value, cb) < 0)
> + st = -1;
> if (git_color_default_config(var, value, cb) < 0)
> st = -1;
> return st;
>
> What do you think?
I'd be tempted to open code the "grep.threads" case in this function
rather than introducing a helper for a single variable, but I don't
think it matters either way. This looks good.
next prev parent reply other threads:[~2015-10-27 14:11 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-26 12:32 [PATCH v3] Add git-grep threads param Victor Leschuk
2015-10-26 19:32 ` John Keeping
2015-10-27 5:25 ` Victor Leschuk
2015-10-27 11:52 ` John Keeping
2015-10-27 13:54 ` Victor Leschuk
2015-10-27 14:11 ` John Keeping [this message]
[not found] ` <CA+55aFwrU25x25XrRODgS1oRXqN60rmYPiXLgfs3mqRco4Oi9A@mail.gmail.com>
2015-10-27 9:14 ` Victor Leschuk
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20151027141100.GR19802@serenity.lan \
--to=john@keeping.me.uk \
--cc=git@vger.kernel.org \
--cc=vleschuk@accesssoftek.com \
--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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.