New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Performance issue for ocamlbuild on Windows #5201
Comments
Comment author: ertai In the same vein I would also be in favor of not calling the shell when the arguments are either easily quotable or need not to be quoted. |
Comment author: daweil and because ocamlbuild call the "bash" or the "sh" shell, ocamlbuild does'nt work when call direcly called from a DOS shell. |
Comment author: @protz Yes, however, the recommend way to run OCaml under Windows is inside a Cygwin environment (either with the cygwin-packaged ocaml, or the native win32 ocaml compilers) so that you have a shell and the gnu tools available to work with. Argument quoting is such a mess on windows that I don't think it would be easy to make sure ocamlbuild can rely on cmd.exe under windows... |
Comment author: @ygrek FTR see the discussion and referenced articles at https://forge.ocamlcore.org/tracker/?func=detail&aid=1170&group_id=54&atid=291 |
Comment author: Camarade_Tux I've started to look at the issue a bit more in-depth. ocamlbuild uses this for different kinds of commands: 1- is probably the biggest performance killer by far, especially on windows. Spawning bash on msys or cygwin takes time and spawning another command will only be slower. These should be pretty easy to implement. 2- is more annoying. The functions "run_and_*" seem to be usable by plugins but maybe not officially (can someone confirm this?). Overall it would be nicer to avoid such functions or reduce their number (some are easy: there's a call to readlink). There will still be a few calls ("ocamlfind list" for instance) anyway. In ygrek's link, thelema has implemented the necessary quoting in ocaml; would it be possible to include this in the standard library? Unix.exec* functions should also be rewritten to use that quoting. Moving the run_and_* functions from ocamlbuild to the standard library would probably be good too since they're already in the ocaml sources and are needed by projects which cannot easily use an additional library (ocamlbuild, my yypkg package manager, probably omake, ocamlfind, godi, ...). So, does removing as many calls to external commands as possible and adding support for proper quoting for processes in the standard library sound like a good way? PS: this issue should be made linked to "#4981: ocamlbuild/my_std.ml shouldn't call bash" in mantis. |
Comment author: daweil I made some more test this last version of ocaml (4.01).
So, if bash cannot be removed, why not patching my_std.ml by "let cmd = "bash --norc -c "^Filename.quote cmd in" ? |
Comment author: @gasche I know nothing about Windows, so please bear with me if I have stupid
[...]
My understanding is that by passing option -c as ocamlbuild already |
Comment author: Camarade_Tux Btw, quoting bash's manpage: Back to removing the need for bash, I've read specs and explanations more and I believe the only way is to rely on Unix.create_process* and not others. |
Comment author: @gasche I'm waiting for feedback from daweil on whether --norc really makes a difference. |
Comment author: daweil Yes, the --norc options makes a difference on Windows, but only 30% better, cf my note on July 29th. |
Comment author: @gasche I committed the addition of the --norc option. I'm leaving the bug open as a place to welcome patches to remove some of the bash invocations in ocamlbuild (hint hint). |
Comment author: @damiendoligez ocamlbuild is now a separate project that lives on GitHub. |
Original bug ID: 5201
Reporter: daweil
Status: resolved (set by @damiendoligez on 2017-02-27T14:16:28Z)
Resolution: suspended
Priority: normal
Severity: tweak
Platform: Windows
OS: XP
OS Version: 2
Version: 3.12.0
Target version: later
Category: -for ocamlbuild use https://github.com/ocaml/ocamlbuild/issues
Related to: #4981
Monitored by: @gasche @ygrek Camarade_Tux @jberdine
Bug description
on Windows system, each command executed by ocambuild is encapsulated in a "bash -C" command which has a non negligeable overhead (~ 0.5s).
Unless the Filename.quote function is fixed, a simple improvement is to change a line in file ocamlbuild/my_std.ml,
In function sys_command, just replace the line
let cmd = "bash -c "^Filename.quote cmd in
by
let cmd = "sh -c "^Filename.quote cmd in
ocamlbuild will go much faster on Windows.
The text was updated successfully, but these errors were encountered: