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

[PATCH v2 0/4] Reduce number of processes spawned by git-mergetool

From
Johannes Sixt <j6t@kdbg.org>
Date
Jun 12, 2019, 16:33 UTC
Message-ID
<cover.1560356675.git.j6t@kdbg.org>
In-Reply-To
<cover.1560152205.git.j6t@kdbg.org>

git-mergetool spawns an enormous amount of processes. For this reason, the test script, t7610, is exceptionally slow, in particular, on Windows. Most of the processes are invocations of git. There are also some that can be replaced with shell builtins.

I've measured the number of processes and the number of non-git commands invoked with

  strace -e execve,clone -f -o /tmp/git.strace ./t7610-mergetool.sh
  # processes:
  grep 'stack=NULL' /tmp/git.strace | wc -l
  # non-git commands:
  grep 'execve(' /tmp/git.strace | grep -v 'execve(".home' | wc -l
          non-git
processes commands
13775     3082    baseline
13690     3082    t7610-mergetool: do not place pipelines headed by `yes` in subshells
13645     3082    t7610-mergetool: use test_cmp instead of test $(cat file) = $txt
13084     2521    mergetool: dissect strings with shell variable magic instead of `expr`
11542     2007    mergetool: use shell variable magic instead of `awk`
Notes on v2:
- Followed Gábor's suggestion to transform test ($cat ..) = txt
  (new patch 2).  It does not help a lot, but neither does
  patch 1, the pipe-in-subshell conversion.  Both are foremost
  clean-ups.
- Commit message tweaks; see below.
- Did not include measurement results in the commit messages, because
  I would have to repeat the measurement method every time.
Johannes Sixt (4):
  t7610-mergetool: do not place pipelines headed by `yes` in subshells
  t7610-mergetool: use test_cmp instead of test $(cat file) = $txt
  mergetool: dissect strings with shell variable magic instead of `expr`
  mergetool: use shell variable magic instead of `awk`
 git-mergetool.sh     |  45 +++++--
 t/t7610-mergetool.sh | 309 +++++++++++++++++++++++++------------------
 2 files changed, 208 insertions(+), 146 deletions(-)
Range-diff against v1:
1:  75c812bd48 = 1:  75c812bd48 t7610-mergetool: do not place pipelines headed by `yes` in subshells
-:  ---------- > 2:  82bafc90de t7610-mergetool: use test_cmp instead of test $(cat file) = $txt
2:  2a33ca20af ! 3:  ad34a9a7ab mergetool: dissect strings with shell variable magic instead of `expr`
    @@ -4,7 +4,7 @@
     
         git-mergetool spawns an enormous amount of processes. For this reason,
         the test script, t7610, is exceptionally slow, in particular, on
    -    Windows. Most of the processes are invocations of git, but there are
    +    Windows. Most of the processes are invocations of git. There are
         also some that can be replaced with shell builtins. Do so with `expr`.
     
         Signed-off-by: Johannes Sixt <j6t@kdbg.org>
3:  d6675b0291 ! 4:  99a6a89339 mergetool: use shell variable magic instead of `awk`
    @@ -4,7 +4,7 @@
     
         git-mergetool spawns an enormous amount of processes. For this reason,
         the test script, t7610, is exceptionally slow, in particular, on
    -    Windows. Most of the processes are invocations of git, but there are
    +    Windows. Most of the processes are invocations of git. There are
         also some that can be replaced with shell builtins. Avoid repeated
         calls of `git ls-files` and `awk`.
     
-- 
2.21.0.285.gc38d92e052
Previous: Johannes SixtNext: Johannes Sixt
Message 14 of 18 in “Reduce number of processes spawned by git-mergetool”
  1. 0/3 Reduce number of processes spawned by git-mergetoolJohannes Sixt, Jun 10, 2019
  2. 1/3 t7610-mergetool: do not place pipelines headed by `yes` in subshellsJohannes Sixt, Jun 10, 2019
  3. SZEDER GáborJun 10, 2019
  4. Junio C HamanoJun 10, 2019
  5. SZEDER GáborJun 10, 2019
  6. Johannes SchindelinJun 10, 2019
  7. SZEDER GáborJun 10, 2019
  8. 2/3 mergetool: dissect strings with shell variable magic instead of `expr`Johannes Sixt, Jun 10, 2019
  9. Junio C HamanoJun 10, 2019
  10. Johannes SixtJun 10, 2019
  11. 3/3 mergetool: use shell variable magic instead of `awk`Johannes Sixt, Jun 10, 2019
  12. Junio C HamanoJun 10, 2019
  13. Johannes SixtJun 10, 2019
  14. 0/4 Reduce number of processes spawned by git-mergetoolJohannes Sixt, Jun 12, 2019
  15. 3/4 mergetool: dissect strings with shell variable magic instead of `expr`Johannes Sixt, Jun 12, 2019
  16. 4/4 mergetool: use shell variable magic instead of `awk`Johannes Sixt, Jun 12, 2019
  17. 1/4 t7610-mergetool: do not place pipelines headed by `yes` in subshellsJohannes Sixt, Jun 12, 2019
  18. 2/4 t7610-mergetool: use test_cmp instead of test $(cat file) = $txtJohannes Sixt, Jun 12, 2019

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.