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

Re: A potential approach to making tests faster on Windows

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Apr 3, 2018, 11:43 UTC
Message-ID
<nycvar.QRO.7.76.6.1804031150030.5026@qfpub.tvgsbejvaqbjf.bet>
In-Reply-To
<87fu4hwgfa.fsf@evledraar.gmail.com>
Hi Ævar,
On Fri, 30 Mar 2018, Ævar Arnfjörð Bjarmason wrote:
> On Fri, Mar 30 2018, Johannes Schindelin wrote [expressing frustrations
> about Windows test suite slowness]:

To be precise (and I think it is important to be precise here): it is not the Windows test suite about which I talked, it is Git's test suite, as run on Windows. It might sound like a small difference, but it is not: the fault really lies with Git because it wants to be a portable software.

> I've wondered for a while whether it wouldn't be a viable approach to
> make something like an interpreter for our test suite to get around this
> problem, i.e. much of it's very repetitive and just using a few shell
> functions we've defined, what if we had C equivalents of those?
There has even been an attempt to do this by Linus Torvalds himself:
https://public-inbox.org/git/Pine.LNX.4.64.0602232229340.3771@g5.osdl.org/
It has not really gone anywhere...

To be honest, I had a different idea (because I do not really want to maintain yet another piece of software): BusyBox. The source code is clean enough, and it should, in theory, allow us to go really fast.

> Duy had a WIP patch set a while ago to add C test suite support, but I
> thought what if we turn that inside-out, and instead have a shell
> interpreter that knows about the likes of test_cmp, and executes them
> directly?

The problem, of course, is: if you add Git-test-suite-specific stuff to any Unix shell, you are going to have to maintain this fork, and all of a sudden it has become a lot harder to develop Git, and to port it.

Quite frankly, I would rather go with Duy's original approach, or a variation thereof, as snuck into the wildmatch discussion here:

	https://public-inbox.org/git/20180110090724.GA2893@ash/
Show 45 quoted lines
> Here's proof of concept as a patch to the dash shell:
> 
>     u dash (debian/master=) $ git diff
>     diff --git a/src/builtins.def.in b/src/builtins.def.in
>     index 4441fe4..b214a17 100644
>     --- a/src/builtins.def.in
>     +++ b/src/builtins.def.in
>     @@ -92,3 +92,4 @@ ulimitcmd     ulimit
>      #endif
>      testcmd                test [
>      killcmd                -u kill
>     +testcmpcmd     test_cmp
>     diff --git a/src/jobs.c b/src/jobs.c
>     index c2c2332..905563f 100644
>     --- a/src/jobs.c
>     +++ b/src/jobs.c
>     @@ -1502,3 +1502,12 @@ getstatus(struct job *job) {
>                     jobno(job), job->nprocs, status, retval));
>             return retval;
>      }
>     +
>     +#include <stdio.h>
>     +int
>     +testcmpcmd(argc, argv)
>     +       int argc;
>     +       char **argv;
>     +{
>     +       fprintf(stderr, "Got %d arguments\n", argc);
>     +}
> 
> I just added that to jobs.c because it was easiest, then test_cmp
> becomes a builtin:
> 
>     u dash (debian/master=) $ src/dash -c 'type test_cmp'
>     test_cmp is a shell builtin
>     u dash (debian/master=) $ src/dash -c 'echo foo && test_cmp 1 2 3'
>     foo
>     Got 4 arguments
> 
> I.e. it's really easy to add new built in commands to the dash shell
> (and probably other shells, but dash is really small & fast).
> 
> We could carry some patch like that to dash, and also patch it so
> test-lib.sh could know that that was our own custom shell, and we'd then
> skip defining functions like test_cmp, and instead use that new builtin.
Or even use the output of `type test_cmp` as a tell-tale.
Show 11 quoted lines
> Similarly, it could then be linked to our own binaries, and the
> test-tool would be a builtin that would appropriately dispatch, and we
> could even eventually make "git" a shell builtin.
> 
> I don't have time or interest to work on this now, but thought it was
> interesting to share. This assumes that something in shellscript like:
> 
>     while echo foo; do echo bar; done
> 
> Is no slower on Windows than *nix, since it's purely using built-ins, as
> opposed to something that would shell out.

It is still interpreting stuff. And it still goes through the POSIX emulation layer.

I did see reports on the Git for Windows bug tracker that gave me the impression that such loops in Unix shell scripts may not, in fact, be as performant in MSYS2's Bash as you would like to believe:

https://github.com/git-for-windows/git/issues/1533#issuecomment-372025449

Ciao, Dscho

Previous: Eric SunshineNext: Jeff King
Message 24 of 103 in “Assorted fixes for `git config` (including the "empty sections" bug)”
  1. 0/9 Assorted fixes for `git config` (including the "empty sections" bug)Johannes Schindelin, Mar 29, 2018
  2. 1/9 git_config_set: fix off-by-twoJohannes Schindelin, Mar 29, 2018
  3. Stefan BellerMar 29, 2018
  4. Jeff KingMar 29, 2018
  5. Johannes SchindelinMar 30, 2018
  6. Ævar Arnfjörð BjarmasonMar 30, 2018
  7. Junio C HamanoMar 30, 2018
  8. Johannes SchindelinMar 30, 2018
  9. Junio C HamanoMar 30, 2018
  10. Johannes SchindelinApr 3, 2018
  11. Duy NguyenApr 3, 2018
  12. Johannes SchindelinApr 3, 2018
  13. Junio C HamanoApr 8, 2018
  14. Duy NguyenMar 30, 2018
  15. Johannes SchindelinMar 30, 2018
  16. Duy NguyenMar 30, 2018
  17. A potential approach to making tests faster on WindowsÆvar Arnfjörð Bjarmason, Mar 30, 2018
  18. Junio C HamanoMar 30, 2018
  19. Jeff KingMar 30, 2018
  20. Johannes SchindelinApr 3, 2018
  21. Ævar Arnfjörð BjarmasonApr 3, 2018
  22. Johannes SchindelinApr 3, 2018
  23. Eric SunshineApr 3, 2018
  24. Johannes SchindelinApr 3, 2018
  25. Jeff KingApr 3, 2018
  26. Johannes SchindelinApr 3, 2018
  27. Jeff KingApr 6, 2018
  28. Stefan BellerApr 6, 2018
  29. 2/9 t1300: rename it to reflect that `repo-config` was deprecatedJohannes Schindelin, Mar 29, 2018
  30. Jeff KingMar 29, 2018
  31. Johannes SchindelinMar 30, 2018
  32. 3/9 t1300: avoid relying on a bugJohannes Schindelin, Mar 29, 2018
  33. Jeff KingMar 29, 2018
  34. Johannes SchindelinMar 30, 2018
  35. 5/9 t1300: `--unset-all` can leave an empty section behind (bug)Johannes Schindelin, Mar 29, 2018
  36. Jeff KingMar 29, 2018
  37. 4/9 t1300: remove unreasonable expectation from TODOJohannes Schindelin, Mar 29, 2018
  38. Jeff KingMar 29, 2018
  39. Junio C HamanoMar 29, 2018
  40. Johannes SchindelinMar 30, 2018
  41. 6/9 git_config_set: simplify the way the section name is rememberedJohannes Schindelin, Mar 29, 2018
  42. 7/9 git config --unset: remove empty sections (in normal situations)Johannes Schindelin, Mar 29, 2018
  43. Jeff KingMar 29, 2018
  44. Johannes SchindelinMar 30, 2018
  45. Jeff KingMar 30, 2018
  46. 8/9 git_config_set: use do_config_from_file() directlyJohannes Schindelin, Mar 29, 2018
  47. Jeff KingMar 29, 2018
  48. Johannes SchindelinMar 30, 2018
  49. Jeff KingMar 30, 2018
  50. Johannes SchindelinMar 30, 2018
  51. Jeff KingMar 30, 2018
  52. Johannes SchindelinMar 30, 2018
  53. 9/9 git_config_set: reuse empty sectionsJohannes Schindelin, Mar 29, 2018
  54. Jeff KingMar 29, 2018
  55. Johannes SchindelinMar 30, 2018
  56. Stefan BellerMar 29, 2018
  57. Johannes SchindelinMar 30, 2018
  58. Jeff KingMar 29, 2018
  59. Johannes SchindelinMar 30, 2018
  60. Ævar Arnfjörð BjarmasonMar 30, 2018
  61. Johannes SchindelinMar 30, 2018
  62. 00/15 Assorted fixes for `git config` (including the "empty sections" bug)Johannes Schindelin, Apr 3, 2018
  63. 01/15 git_config_set: fix off-by-twoJohannes Schindelin, Apr 3, 2018
  64. 02/15 t1300: rename it to reflect that `repo-config` was deprecatedJohannes Schindelin, Apr 3, 2018
  65. 03/15 t1300: demonstrate that --replace-all can "invent" newlinesJohannes Schindelin, Apr 3, 2018
  66. 04/15 config --replace-all: avoid extra line breaksJohannes Schindelin, Apr 3, 2018
  67. 05/15 t1300: avoid relying on a bugJohannes Schindelin, Apr 3, 2018
  68. 06/15 t1300: remove unreasonable expectation from TODOJohannes Schindelin, Apr 3, 2018
  69. 07/15 t1300: `--unset-all` can leave an empty section behind (bug)Johannes Schindelin, Apr 3, 2018
  70. 08/15 config: introduce an optional event stream while parsingJohannes Schindelin, Apr 3, 2018
  71. Jeff KingApr 6, 2018
  72. Johannes SchindelinApr 9, 2018
  73. 09/15 config: avoid using the global variable `store`Johannes Schindelin, Apr 3, 2018
  74. Jeff KingApr 6, 2018
  75. Johannes SchindelinApr 9, 2018
  76. 10/15 config_set_store: rename some fields for consistencyJohannes Schindelin, Apr 3, 2018
  77. 11/15 git_config_set: do not use a state machineJohannes Schindelin, Apr 3, 2018
  78. Jeff KingApr 6, 2018
  79. Johannes SchindelinApr 9, 2018
  80. 12/15 git_config_set: make use of the config parser's event streamJohannes Schindelin, Apr 3, 2018
  81. 13/15 git config --unset: remove empty sections (in the common case)Johannes Schindelin, Apr 3, 2018
  82. 14/15 git_config_set: reuse empty sectionsJohannes Schindelin, Apr 3, 2018
  83. Johannes SchindelinApr 3, 2018
  84. Jeff KingApr 6, 2018
  85. Johannes SchindelinApr 9, 2018
  86. 00/15 Assorted fixes for `git config` (including the "empty sections" bug)Johannes Schindelin, Apr 9, 2018
  87. 01/15 git_config_set: fix off-by-twoJohannes Schindelin, Apr 9, 2018
  88. 03/15 t1300: demonstrate that --replace-all can "invent" newlinesJohannes Schindelin, Apr 9, 2018
  89. 04/15 config --replace-all: avoid extra line breaksJohannes Schindelin, Apr 9, 2018
  90. 02/15 t1300: rename it to reflect that `repo-config` was deprecatedJohannes Schindelin, Apr 9, 2018
  91. 05/15 t1300: avoid relying on a bugJohannes Schindelin, Apr 9, 2018
  92. 06/15 t1300: remove unreasonable expectation from TODOJohannes Schindelin, Apr 9, 2018
  93. 07/15 t1300: add a few more hairy examples of sections becoming emptyJohannes Schindelin, Apr 9, 2018
  94. 08/15 t1300: `--unset-all` can leave an empty section behind (bug)Johannes Schindelin, Apr 9, 2018
  95. 09/15 config: introduce an optional event stream while parsingJohannes Schindelin, Apr 9, 2018
  96. 10/15 config: avoid using the global variable `store`Johannes Schindelin, Apr 9, 2018
  97. 11/15 config_set_store: rename some fields for consistencyJohannes Schindelin, Apr 9, 2018
  98. 12/15 git_config_set: do not use a state machineJohannes Schindelin, Apr 9, 2018
  99. 13/15 git_config_set: make use of the config parser's event streamJohannes Schindelin, Apr 9, 2018
  100. Jeff KingMay 8, 2018
  101. Jeff KingMay 8, 2018
  102. 14/15 git config --unset: remove empty sections (in the common case)Johannes Schindelin, Apr 9, 2018
  103. 15/15 git_config_set: reuse empty sectionsJohannes Schindelin, Apr 9, 2018

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.