Add git-grep threads param
PATCH v6 1/1 Add git-grep threads param
"git grep" can now be configured (or told from the command line)
how many threads to use when searching in the working tree files.
Changes to default behavior: number of threads now doesn't depend on online_cpus(), e.g. if specific number is not configured GREP_NUM_THREADS_DEFAULT (8) threads will be used even on 1-core CPU.
---
History of changes from the first version ($gmane/280053/:
* Param renamed from threads-num to threads
* Short version of '--threads' cmd key was removed
* Made num_threads 'decision-tree' more obvious
and easy to edit for future use ($gmane/280089)
* Moved option description to more suitable place in documentation ($gmane/280188)
* Hid threads param from 'external' grep.c, made it private for builtin/grep.c ($gmane/280188)
* Improved num_threads 'decision-tree', got rid of dependency on online_cpus ($gmane/280299)
* Improved param documentation ($gmane/280299)
Documentation/config.txt | 7 +++++ Documentation/git-grep.txt | 15 ++++++++++ builtin/grep.c | 50 +++++++++++++++++++++++----------- contrib/completion/git-completion.bash | 1 + 4 files changed, 57 insertions(+), 16 deletions(-)
Documentation/config.txt +7 -0
@@ -1447,6 +1447,13 @@ grep.extendedRegexp:: option is ignored when the 'grep.patternType' option is set to a value other than 'default'. +grep.threads:: + Number of grep worker threads, use it to tune up performance on + your machines. Leave it unset (or set to 0) for default behavior, + which for now is using 8 threads for all systems. + Default behavior can be changed in future versions + to better suit hardware and circumstances. + gpg.program:: Use this custom program instead of "gpg" found on $PATH when making or verifying a PGP signature. The program must support the
Documentation/git-grep.txt +15 -0
@@ -23,6 +23,7 @@ SYNOPSIS [--break] [--heading] [-p | --show-function] [-A <post-context>] [-B <pre-context>] [-C <context>] [-W | --function-context] + [--threads <num>] [-f <file>] [-e] <pattern> [--and|--or|--not|(|)|-e <pattern>...] [ [--[no-]exclude-standard] [--cached | --no-index | --untracked] | <tree>...]
@@ -53,6 +54,13 @@ grep.extendedRegexp:: option is ignored when the 'grep.patternType' option is set to a value other than 'default'. +grep.threads:: + Number of grep worker threads, use it to tune up performance on + your machines. Leave it unset (or set to 0) for default behavior, + which for now is using 8 threads for all systems. + Default behavior can be changed in future versions + to better suit hardware and circumstances. + grep.fullName:: If set to true, enable '--full-name' option by default.
@@ -227,6 +235,13 @@ OPTIONS effectively showing the whole function in which the match was found. +--threads <num>:: + Number of grep worker threads, use it to tune up performance on + your machines. Leave it unset (or set to 0) for default behavior, + which for now is using 8 threads for all systems. + Default behavior can be changed in future versions + to better suit hardware and circumstances. + -f <file>:: Read patterns from <file>, one per line.
builtin/grep.c +34 -16
135 lines not on this page · raw message
contrib/completion/git-completion.bash +1 -0
@@ -1310,6 +1310,7 @@ _git_grep () --full-name --line-number --extended-regexp --basic-regexp --fixed-strings --perl-regexp + --threads --files-with-matches --name-only --files-without-match --max-depth
Signature · 1 line
2.6.3.369.g3e7f205.dirty
Hello all,
The earlier version of this patch is already included in /pu branch, however as we all agreed ($gmane/280299) we have changed the default behavior and the meaning of "0". The question is: what is the right way to include changes from patch v6 (this one) into already merged patch to pu?
Thanks.
--
Best Regards,
Victor
________________________________________
From: Victor Leschuk [[email protected]]
Sent: Wednesday, November 11, 2015 03:52
To: [email protected]
Cc: Victor Leschuk
Subject: [PATCH v6] Add git-grep threads param
"git grep" can now be configured (or told from the command line)
how many threads to use when searching in the working tree files.
Changes to default behavior: number of threads now doesn't depend on online_cpus(), e.g. if specific number is not configured GREP_NUM_THREADS_DEFAULT (8) threads will be used even on 1-core CPU.
---
History of changes from the first version ($gmane/280053/:
* Param renamed from threads-num to threads
* Short version of '--threads' cmd key was removed
* Made num_threads 'decision-tree' more obvious
and easy to edit for future use ($gmane/280089)
* Moved option description to more suitable place in documentation ($gmane/280188)
* Hid threads param from 'external' grep.c, made it private for builtin/grep.c ($gmane/280188)
* Improved num_threads 'decision-tree', got rid of dependency on online_cpus ($gmane/280299)
* Improved param documentation ($gmane/280299)
Documentation/config.txt | 7 +++++ Documentation/git-grep.txt | 15 ++++++++++ builtin/grep.c | 50 +++++++++++++++++++++++----------- contrib/completion/git-completion.bash | 1 + 4 files changed, 57 insertions(+), 16 deletions(-)
Documentation/config.txt +7 -0
@@ -1447,6 +1447,13 @@ grep.extendedRegexp:: option is ignored when the 'grep.patternType' option is set to a value other than 'default'. +grep.threads:: + Number of grep worker threads, use it to tune up performance on + your machines. Leave it unset (or set to 0) for default behavior, + which for now is using 8 threads for all systems. + Default behavior can be changed in future versions + to better suit hardware and circumstances. + gpg.program:: Use this custom program instead of "gpg" found on $PATH when making or verifying a PGP signature. The program must support the
Documentation/git-grep.txt +15 -0
@@ -23,6 +23,7 @@ SYNOPSIS [--break] [--heading] [-p | --show-function] [-A <post-context>] [-B <pre-context>] [-C <context>] [-W | --function-context] + [--threads <num>] [-f <file>] [-e] <pattern> [--and|--or|--not|(|)|-e <pattern>...] [ [--[no-]exclude-standard] [--cached | --no-index | --untracked] | <tree>...]
@@ -53,6 +54,13 @@ grep.extendedRegexp:: option is ignored when the 'grep.patternType' option is set to a value other than 'default'. +grep.threads:: + Number of grep worker threads, use it to tune up performance on + your machines. Leave it unset (or set to 0) for default behavior, + which for now is using 8 threads for all systems. + Default behavior can be changed in future versions + to better suit hardware and circumstances. + grep.fullName:: If set to true, enable '--full-name' option by default.
@@ -227,6 +235,13 @@ OPTIONS effectively showing the whole function in which the match was found. +--threads <num>:: + Number of grep worker threads, use it to tune up performance on + your machines. Leave it unset (or set to 0) for default behavior, + which for now is using 8 threads for all systems. + Default behavior can be changed in future versions + to better suit hardware and circumstances. + -f <file>:: Read patterns from <file>, one per line.
builtin/grep.c +34 -16
135 lines not on this page · raw message
contrib/completion/git-completion.bash +1 -0
@@ -1310,6 +1310,7 @@ _git_grep () --full-name --line-number --extended-regexp --basic-regexp --fixed-strings --perl-regexp + --threads --files-with-matches --name-only --files-without-match --max-depth
--
2.6.3.369.g3e7f205.dirty
Quoted 5 lines · Victor Leschuk
The earlier version of this patch is already included in /pu branch, however as we all agreed ($gmane/280299) we have changed the default behavior and the meaning of "0". The question is: what is the right way to include changes from patch v6 (this one) into already merged patch to pu?
Merging to "pu" does not really mean anything; it is simply that the maintainer has picked it up as a possible topic of interest. Patches can (and often are) still re-written in that state.
Junio is on vacation for a few weeks, and I'm acting as maintainer in the interim. I've added your v6 to my pile of patches to look at, but I haven't gone over it carefully yet.
-Peff
Quoted 8 lines · Jeff King
Quoted 5 lines · Victor Leschuk
The earlier version of this patch is already included in /pu branch, however as we all agreed ($gmane/280299) we have changed the default behavior and the meaning of "0". The question is: what is the right way to include changes from patch v6 (this one) into already merged patch to pu?
Quoted 7 lines
Merging to "pu" does not really mean anything; it is simply that the maintainer has picked it up as a possible topic of interest. Patches can (and often are) still re-written in that state.
Junio is on vacation for a few weeks, and I'm acting as maintainer in the interim. I've added your v6 to my pile of patches to look at, but I haven't gone over it carefully yet.
To be perfectly explicit: Patches in 'pu' get replaced wholesale by newer versions, so you would simply send the new version of the patch in its entirety (as you did with v6).
Hello all,
does anybody have time to review this patch?
PS Sorry for bothering =)
--
Best Regards,
Victor
________________________________________
From: Victor Leschuk [[email protected]]
Sent: Wednesday, November 11, 2015 03:52
To: [email protected]
Cc: Victor Leschuk
Subject: [PATCH v6] Add git-grep threads param
"git grep" can now be configured (or told from the command line)
how many threads to use when searching in the working tree files.
Changes to default behavior: number of threads now doesn't depend on online_cpus(), e.g. if specific number is not configured GREP_NUM_THREADS_DEFAULT (8) threads will be used even on 1-core CPU.
---
History of changes from the first version ($gmane/280053/:
* Param renamed from threads-num to threads
* Short version of '--threads' cmd key was removed
* Made num_threads 'decision-tree' more obvious
and easy to edit for future use ($gmane/280089)
* Moved option description to more suitable place in documentation ($gmane/280188)
* Hid threads param from 'external' grep.c, made it private for builtin/grep.c ($gmane/280188)
* Improved num_threads 'decision-tree', got rid of dependency on online_cpus ($gmane/280299)
* Improved param documentation ($gmane/280299)
Documentation/config.txt | 7 +++++ Documentation/git-grep.txt | 15 ++++++++++ builtin/grep.c | 50 +++++++++++++++++++++++----------- contrib/completion/git-completion.bash | 1 + 4 files changed, 57 insertions(+), 16 deletions(-)
Documentation/config.txt +7 -0
@@ -1447,6 +1447,13 @@ grep.extendedRegexp:: option is ignored when the 'grep.patternType' option is set to a value other than 'default'. +grep.threads:: + Number of grep worker threads, use it to tune up performance on + your machines. Leave it unset (or set to 0) for default behavior, + which for now is using 8 threads for all systems. + Default behavior can be changed in future versions + to better suit hardware and circumstances. + gpg.program:: Use this custom program instead of "gpg" found on $PATH when making or verifying a PGP signature. The program must support the
Documentation/git-grep.txt +15 -0
@@ -23,6 +23,7 @@ SYNOPSIS [--break] [--heading] [-p | --show-function] [-A <post-context>] [-B <pre-context>] [-C <context>] [-W | --function-context] + [--threads <num>] [-f <file>] [-e] <pattern> [--and|--or|--not|(|)|-e <pattern>...] [ [--[no-]exclude-standard] [--cached | --no-index | --untracked] | <tree>...]
@@ -53,6 +54,13 @@ grep.extendedRegexp:: option is ignored when the 'grep.patternType' option is set to a value other than 'default'. +grep.threads:: + Number of grep worker threads, use it to tune up performance on + your machines. Leave it unset (or set to 0) for default behavior, + which for now is using 8 threads for all systems. + Default behavior can be changed in future versions + to better suit hardware and circumstances. + grep.fullName:: If set to true, enable '--full-name' option by default.
@@ -227,6 +235,13 @@ OPTIONS effectively showing the whole function in which the match was found. +--threads <num>:: + Number of grep worker threads, use it to tune up performance on + your machines. Leave it unset (or set to 0) for default behavior, + which for now is using 8 threads for all systems. + Default behavior can be changed in future versions + to better suit hardware and circumstances. + -f <file>:: Read patterns from <file>, one per line.
builtin/grep.c +34 -16
135 lines not on this page · raw message
contrib/completion/git-completion.bash +1 -0
@@ -1310,6 +1310,7 @@ _git_grep () --full-name --line-number --extended-regexp --basic-regexp --fixed-strings --perl-regexp + --threads --files-with-matches --name-only --files-without-match --max-depth
--
2.6.3.369.g3e7f205.dirty
Quoted 6 lines · Victor Leschuk
"git grep" can now be configured (or told from the command line)
how many threads to use when searching in the working tree files.Changes to default behavior: number of threads now doesn't depend on
online_cpus(), e.g. if specific number is not configuredGREP_NUM_THREADS_DEFAULT(8) threads will be used even on 1-core CPU.
Why? (I'm asking for an explanation in the commit message so that I will not have to ask again in future)
builtin/grep.c static void start_threads(struct grep_opt *opt) · line 209
Quoted 6 lines
builtin/grep.c +1
-1@@ -206,7 +206,8 @@ static void start_threads(struct grep_opt *opt)strbuf_init (&todo[i].out,0 ); } -for (i =0 ; i <ARRAY_SIZE (threads); i++) { + threads =xcalloc (num_threads,sizeof (pthread_t));
I think we usually go with sizeof(*threads), but not sure if it's just a personal taste or the preferred style for git.
builtin/grep.c static int wait_all(void) · line 282
Quoted 9 lines
builtin/grep.c +3
-1static int grep_cmd_config (const char *var,const char *value,void *cb) {int st =grep_config (var, value, cb); -if (git_color_default_config (var, value, cb) <0 ) +if (grep_threads_config (var, value, cb) <0 ) + st =-1 ; +else if (git_color_default_config (var, value, cb) <0 ) st =-1 ;return st;
Hm... isn't it simpler to just return -1 instead of assigning to st first? I think you could just merge grep_threads_config() in this function because it's not that complex to stay separate..
Quoted 1 line
}
Signature · 1 line
Duy
I forgot..
builtin/grep.c int cmd_grep(int argc, const char **argv, const char *prefix) · line 854
Quoted 2 lines · Victor Leschuk
builtin/grep.c +2
-0+else if (num_threads <0 ) +die ("Invalid number of threads specified (%d)" , num_threads);
Please wrap this string with _() so it can be translated
Signature · 1 line
Duy
This version seems to break t7811 when applied on top of 37023ba3 (Seventh batch for 2.7, 2015-10-26).
I'll eject it from 'pu' for today's integration.