diff options
author | Matheus Tavares <matheus.bernardino@usp.br> | 2020-01-15 23:39:58 -0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2020-01-17 13:52:14 -0800 |
commit | 1184a95ea21ee780277846723219104597ceca01 (patch) | |
tree | 22352d69f995c22bf02c6e1270fc5a6b11ddb9b3 /builtin | |
parent | grep: protect packed_git [re-]initialization (diff) | |
download | tgif-1184a95ea21ee780277846723219104597ceca01.tar.xz |
grep: re-enable threads in non-worktree case
They were disabled at 53b8d93 ("grep: disable threading in non-worktree
case", 12-12-2011), due to observable performance drops (to the point
that using a single thread would be faster than multiple threads). But
now that zlib inflation can be performed in parallel we can regain the
speedup, so let's re-enable threads in non-worktree grep.
Grepping 'abcd[02]' ("Regex 1") and '(static|extern) (int|double) \*'
("Regex 2") at chromium's repository[1] I got:
Threads | Regex 1 | Regex 2
---------|------------|-----------
1 | 17.2920s | 20.9624s
2 | 9.6512s | 11.3184s
4 | 6.7723s | 7.6268s
8** | 6.2886s | 6.9843s
These are all means of 30 executions after 2 warmup runs. All tests were
executed on an i7-7700HQ (quad-core w/ hyper-threading), 16GB of RAM and
SSD, running Manjaro Linux. But to make sure the optimization also
performs well on HDD, the tests were repeated on another machine with an
i5-4210U (dual-core w/ hyper-threading), 8GB of RAM and HDD (SATA III,
5400 rpm), also running Manjaro Linux:
Threads | Regex 1 | Regex 2
---------|------------|-----------
1 | 18.4035s | 22.5368s
2 | 12.5063s | 14.6409s
4** | 10.9136s | 12.7106s
** Note that in these cases we relied on hyper-threading, and that's
probably why we don't see a big difference in time.
Unfortunately, multithreaded git-grep might be slow in the non-worktree
case when --textconv is used and there're too many text conversions.
Probably the reason for this is that the object read lock is used to
protect fill_textconv() and therefore there is a mutual exclusion
between textconv execution and object reading. Because both are
time-consuming operations, not being able to perform them in parallel
can cause performance drops. To inform the users about this (and other
threading details), let's also add a "NOTES ON THREADS" section to
Documentation/git-grep.txt.
[1]: chromium’s repo at commit 03ae96f (“Add filters testing at DSF=2”,
04-06-2019), after a 'git gc' execution.
Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/grep.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/builtin/grep.c b/builtin/grep.c index 1535fd50f8..6aaa8d4406 100644 --- a/builtin/grep.c +++ b/builtin/grep.c @@ -1054,7 +1054,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix) if (recurse_submodules && (!use_index || untracked)) die(_("option not supported with --recurse-submodules")); - if (list.nr || cached || show_in_pager) { + if (show_in_pager) { if (num_threads > 1) warning(_("invalid option combination, ignoring --threads")); num_threads = 1; |