msys-1.0.dll: Do not start the fstab observer thread.
commita0f5d4ff8977823aff04ea6361d796e5c11bf10a
authorJohannes Sixt <j6t@kdbg.org>
Tue, 29 Dec 2009 21:25:35 +0000 (29 22:25 +0100)
committerJohannes Schindelin <johannes.schindelin@gmx.de>
Mon, 11 Jan 2010 17:41:18 +0000 (11 18:41 +0100)
treeeff067025a9ca39f2f484cd12b7959cf0f6dc13b
parent73adb05cda9bd0c5a3db2a97e754de287805e606
msys-1.0.dll: Do not start the fstab observer thread.

To update mount points while an MSYS program is active, a thread is started
on program startup that observes fstab changes. On program shutdown, this
thread is nowhere terminated explicitly, but only implicitly by
ExitProcess(). Procmon reveals that this takes around 100ms.

The consequence is that when an MSYS program is started from CMD, it takes
at least 100ms, even if it does nothing, such as 'cat < nul'.

The mount point information is shared between MSYS processes, and only the
first one starts this thread and takes the penalty. This is commonly an
interactive bash: nobody cares that it takes 0.1sec to shut down because
all programs that it launches (and their child processes) are not
penalized. But if MSYS programs are run from CMD, the penalty is taken
every time.

This does make a difference when you have a clean or smudge filter
implemented as a bash script *and* you are working from CMD because each
invocation of the script (which happens for each file to which the filter
is applied) takes the penalty.

This patch disables the watcher thread by default, but it can be enabled
by setting the environment variable MSYS_WATCH_FSTAB to a non-empty string
(that does not start with a zero).

A workaround is to start 'cat' in a separate CMD and leave it waiting for
input. This 'cat' counts as the "first" MSYS program and takes the penalty;
all others, even when they are run from a different CMD, do not suffer.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
src/rt/patches/0008-Do-not-start-the-fstab-observer-thread.patch [new file with mode: 0644]