git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/2] Get rid of online_cpus() when determining grep threads num

From
Victor Leschuk <vleschuk@gmail.com>
Date
Dec 15, 2015, 15:31 UTC
Message-ID
<1450193500-22468-3-git-send-email-vleschuk@accesssoftek.com>
In-Reply-To
<1450193500-22468-1-git-send-email-vleschuk@accesssoftek.com>

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.

Reason: multithreading can improve performance even on single core machines
as IO is also a major factor here. Using multiple threads can significantly
boost grep performance when working on slow filesystems (or repo isn't cached)
or through network (for example repo is located on NFS).
Signed-off-by: Victor Leschuk <vleschuk@accesssoftek.com>
---
 builtin/grep.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/builtin/grep.c b/builtin/grep.c
index e9aebab..1315905 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -827,7 +827,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
 	}
 
 #ifndef NO_PTHREADS
-	if (list.nr || cached || online_cpus() == 1 || show_in_pager) {
+	if (list.nr || cached || show_in_pager) {
 		/* Can not multi-thread object lookup */
 		num_threads = 0;
 	}
-- 
2.6.3.369.g3e7f205.dirty
Previous: Eric Sunshine
Message 6 of 6 in “Add git-grep threads param”
  1. 0/2 Add git-grep threads paramVictor Leschuk, Dec 15, 2015
  2. 1/2 Introduce grep threads paramVictor Leschuk, Dec 15, 2015
  3. Junio C HamanoDec 15, 2015
  4. Victor LeschukDec 15, 2015
  5. Eric SunshineDec 16, 2015
  6. 2/2 Get rid of online_cpus() when determining grep threads numVictor Leschuk, Dec 15, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.