grep: disable threading in non-worktree case

Measurements by various people have shown that grepping in parallel is
not beneficial when the object store is involved.  For example, with a
simple regex:

  Threads     | --cached case            | worktree case
  ----------------------------------------------------------------
  8 (default) | 2.88u 0.21s 0:02.94real  | 0.19u 0.32s 0:00.16real
  4           | 2.89u 0.29s 0:02.99real  | 0.16u 0.34s 0:00.17real
  2           | 2.83u 0.36s 0:02.87real  | 0.18u 0.32s 0:00.26real
  NO_PTHREADS | 2.16u 0.08s 0:02.25real  | 0.12u 0.17s 0:00.31real

This happens because all the threads contend on read_sha1_mutex almost
all of the time.  A more complex regex allows the threads to do more
work in parallel, but as Jeff King found out, the "super boost" (much
higher clock when only one core is active) feature of recent CPUs
still causes the unthreaded case to win by a large margin.

So until the pack machinery allows unthreaded access, we disable
grep's threading in all but the worktree case.

Helped-by: René Scharfe <rene.scharfe@lsrfire.ath.cx>
Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Thomas Rast <trast@student.ethz.ch>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 file changed
tree: 72599a8be5639a34231de0de586a670be62ffc3e
  1. block-sha1/
  2. builtin/
  3. compat/
  4. contrib/
  5. Documentation/
  6. git-gui/
  7. git_remote_helpers/
  8. gitk-git/
  9. gitweb/
  10. mergetools/
  11. perl/
  12. po/
  13. ppc/
  14. t/
  15. templates/
  16. vcs-svn/
  17. xdiff/
  18. .gitattributes
  19. .gitignore
  20. .mailmap
  21. abspath.c
  22. aclocal.m4
  23. advice.c
  24. advice.h
  25. alias.c
  26. alloc.c
  27. archive-tar.c
  28. archive-zip.c
  29. archive.c
  30. archive.h
  31. argv-array.c
  32. argv-array.h
  33. attr.c
  34. attr.h
  35. base85.c
  36. bisect.c
  37. bisect.h
  38. blob.c
  39. blob.h
  40. branch.c
  41. branch.h
  42. builtin.h
  43. bundle.c
  44. bundle.h
  45. cache-tree.c
  46. cache-tree.h
  47. cache.h
  48. check-builtins.sh
  49. check-racy.c
  50. check_bindir
  51. color.c
  52. color.h
  53. combine-diff.c
  54. command-list.txt
  55. commit.c
  56. commit.h
  57. config.c
  58. config.mak.in
  59. configure.ac
  60. connect.c
  61. connected.c
  62. connected.h
  63. convert.c
  64. convert.h
  65. copy.c
  66. COPYING
  67. csum-file.c
  68. csum-file.h
  69. ctype.c
  70. daemon.c
  71. date.c
  72. decorate.c
  73. decorate.h
  74. delta.h
  75. diff-delta.c
  76. diff-lib.c
  77. diff-no-index.c
  78. diff.c
  79. diff.h
  80. diffcore-break.c
  81. diffcore-delta.c
  82. diffcore-order.c
  83. diffcore-pickaxe.c
  84. diffcore-rename.c
  85. diffcore.h
  86. dir.c
  87. dir.h
  88. editor.c
  89. entry.c
  90. environment.c
  91. exec_cmd.c
  92. exec_cmd.h
  93. fast-import.c
  94. fetch-pack.h
  95. fixup-builtins
  96. fmt-merge-msg.h
  97. fsck.c
  98. fsck.h
  99. generate-cmdlist.sh
  100. gettext.c
  101. gettext.h
  102. git-add--interactive.perl
  103. git-am.sh
  104. git-archimport.perl
  105. git-bisect.sh
  106. git-compat-util.h
  107. git-cvsexportcommit.perl
  108. git-cvsimport.perl
  109. git-cvsserver.perl
  110. git-difftool--helper.sh
  111. git-difftool.perl
  112. git-filter-branch.sh
  113. git-instaweb.sh
  114. git-lost-found.sh
  115. git-merge-octopus.sh
  116. git-merge-one-file.sh
  117. git-merge-resolve.sh
  118. git-mergetool--lib.sh
  119. git-mergetool.sh
  120. git-parse-remote.sh
  121. git-pull.sh
  122. git-quiltimport.sh
  123. git-rebase--am.sh
  124. git-rebase--interactive.sh
  125. git-rebase--merge.sh
  126. git-rebase.sh
  127. git-relink.perl
  128. git-remote-testgit.py
  129. git-repack.sh
  130. git-request-pull.sh
  131. git-send-email.perl
  132. git-sh-i18n.sh
  133. git-sh-setup.sh
  134. git-stash.sh
  135. git-submodule.sh
  136. git-svn.perl
  137. GIT-VERSION-GEN
  138. git-web--browse.sh
  139. git.c
  140. git.spec.in
  141. gpg-interface.c
  142. gpg-interface.h
  143. graph.c
  144. graph.h
  145. grep.c
  146. grep.h
  147. hash.c
  148. hash.h
  149. help.c
  150. help.h
  151. hex.c
  152. http-backend.c
  153. http-fetch.c
  154. http-push.c
  155. http-walker.c
  156. http.c
  157. http.h
  158. ident.c
  159. imap-send.c
  160. INSTALL
  161. kwset.c
  162. kwset.h
  163. levenshtein.c
  164. levenshtein.h
  165. LGPL-2.1
  166. list-objects.c
  167. list-objects.h
  168. ll-merge.c
  169. ll-merge.h
  170. lockfile.c
  171. log-tree.c
  172. log-tree.h
  173. mailmap.c
  174. mailmap.h
  175. Makefile
  176. match-trees.c
  177. merge-file.c
  178. merge-file.h
  179. merge-recursive.c
  180. merge-recursive.h
  181. name-hash.c
  182. notes-cache.c
  183. notes-cache.h
  184. notes-merge.c
  185. notes-merge.h
  186. notes.c
  187. notes.h
  188. object.c
  189. object.h
  190. pack-check.c
  191. pack-refs.c
  192. pack-refs.h
  193. pack-revindex.c
  194. pack-revindex.h
  195. pack-write.c
  196. pack.h
  197. pager.c
  198. parse-options-cb.c
  199. parse-options.c
  200. parse-options.h
  201. patch-delta.c
  202. patch-ids.c
  203. patch-ids.h
  204. path.c
  205. pkt-line.c
  206. pkt-line.h
  207. preload-index.c
  208. pretty.c
  209. progress.c
  210. progress.h
  211. quote.c
  212. quote.h
  213. reachable.c
  214. reachable.h
  215. read-cache.c
  216. README
  217. reflog-walk.c
  218. reflog-walk.h
  219. refs.c
  220. refs.h
  221. remote-curl.c
  222. remote.c
  223. remote.h
  224. replace_object.c
  225. rerere.c
  226. rerere.h
  227. resolve-undo.c
  228. resolve-undo.h
  229. revision.c
  230. revision.h
  231. run-command.c
  232. run-command.h
  233. send-pack.h
  234. sequencer.c
  235. sequencer.h
  236. server-info.c
  237. setup.c
  238. sh-i18n--envsubst.c
  239. sha1-array.c
  240. sha1-array.h
  241. sha1-lookup.c
  242. sha1-lookup.h
  243. sha1_file.c
  244. sha1_name.c
  245. shallow.c
  246. shell.c
  247. shortlog.h
  248. show-index.c
  249. sideband.c
  250. sideband.h
  251. sigchain.c
  252. sigchain.h
  253. strbuf.c
  254. strbuf.h
  255. streaming.c
  256. streaming.h
  257. string-list.c
  258. string-list.h
  259. submodule.c
  260. submodule.h
  261. symlinks.c
  262. tag.c
  263. tag.h
  264. tar.h
  265. test-chmtime.c
  266. test-ctype.c
  267. test-date.c
  268. test-delta.c
  269. test-dump-cache-tree.c
  270. test-genrandom.c
  271. test-index-version.c
  272. test-line-buffer.c
  273. test-match-trees.c
  274. test-mktemp.c
  275. test-obj-pool.c
  276. test-parse-options.c
  277. test-path-utils.c
  278. test-run-command.c
  279. test-sha1.c
  280. test-sha1.sh
  281. test-sigchain.c
  282. test-string-pool.c
  283. test-subprocess.c
  284. test-svn-fe.c
  285. test-treap.c
  286. thread-utils.c
  287. thread-utils.h
  288. trace.c
  289. transport-helper.c
  290. transport.c
  291. transport.h
  292. tree-diff.c
  293. tree-walk.c
  294. tree-walk.h
  295. tree.c
  296. tree.h
  297. unimplemented.sh
  298. unpack-trees.c
  299. unpack-trees.h
  300. upload-pack.c
  301. url.c
  302. url.h
  303. usage.c
  304. userdiff.c
  305. userdiff.h
  306. utf8.c
  307. utf8.h
  308. walker.c
  309. walker.h
  310. wrap-for-bin.sh
  311. wrapper.c
  312. write_or_die.c
  313. ws.c
  314. wt-status.c
  315. wt-status.h
  316. xdiff-interface.c
  317. xdiff-interface.h
  318. zlib.c