<feed xmlns='http://www.w3.org/2005/Atom'>
<title>delta/git.git, branch hv/mingw-help-is-executable</title>
<subtitle>github.com: git/git.git
</subtitle>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/git.git/'/>
<entry>
<title>help: improve is_executable() on Windows</title>
<updated>2017-01-30T17:04:17+00:00</updated>
<author>
<name>Heiko Voigt</name>
<email>hvoigt@hvoigt.net</email>
</author>
<published>2017-01-30T12:40:58+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/git.git/commit/?id=c755015f79ac03bb5afa0754c30e937887fc68ab'/>
<id>c755015f79ac03bb5afa0754c30e937887fc68ab</id>
<content type='text'>
On Windows, executables need to have the file extension `.exe`, or they
are not executables. Hence, to support scripts, Git for Windows also
looks for a she-bang line by opening the file in question, and executing
it via the specified script interpreter.

To figure out whether files in the `PATH` are executable, `git help` has
code that imitates this behavior. With one exception: it *always* opens
the files and looks for a she-bang line *or* an `MZ` tell-tale
(nevermind that files with the magic `MZ` but without file extension
`.exe` would still not be executable).

Opening this many files leads to performance problems that are even more
serious when a virus scanner is running. Therefore, let's change the
code to look for the file extension `.exe` early, and avoid opening the
file altogether if we already know that it is executable.

See the following measurements (in seconds) as an example, where we
execute a simple program that simply lists the directory contents and
calls open() on every listed file:

With virus scanner running (coldcache):

$ ./a.exe /libexec/git-core/
before open (git-add.exe): 0.000000
after open (git-add.exe): 0.412873
before open (git-annotate.exe): 0.000175
after open (git-annotate.exe): 0.397925
before open (git-apply.exe): 0.000243
after open (git-apply.exe): 0.399996
before open (git-archive.exe): 0.000147
after open (git-archive.exe): 0.397783
before open (git-bisect--helper.exe): 0.000160
after open (git-bisect--helper.exe): 0.397700
before open (git-blame.exe): 0.000160
after open (git-blame.exe): 0.399136
...

With virus scanner running (hotcache):

$ ./a.exe /libexec/git-core/
before open (git-add.exe): 0.000000
after open (git-add.exe): 0.000325
before open (git-annotate.exe): 0.000229
after open (git-annotate.exe): 0.000177
before open (git-apply.exe): 0.000167
after open (git-apply.exe): 0.000150
before open (git-archive.exe): 0.000154
after open (git-archive.exe): 0.000156
before open (git-bisect--helper.exe): 0.000132
after open (git-bisect--helper.exe): 0.000180
before open (git-blame.exe): 0.000718
after open (git-blame.exe): 0.000724
...

With this patch I get:

$ time git help git
Launching default browser to display HTML ...

real    0m8.723s
user    0m0.000s
sys     0m0.000s

and without

$ time git help git
Launching default browser to display HTML ...

real    1m37.734s
user    0m0.000s
sys     0m0.031s

both tests with cold cache and giving the machine some time to settle
down after restart.

[jes: adjusted the commit message]

Signed-off-by: Heiko Voigt &lt;heiko.voigt@mahr.de&gt;
Signed-off-by: Johannes Schindelin &lt;johannes.schindelin@gmx.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
On Windows, executables need to have the file extension `.exe`, or they
are not executables. Hence, to support scripts, Git for Windows also
looks for a she-bang line by opening the file in question, and executing
it via the specified script interpreter.

To figure out whether files in the `PATH` are executable, `git help` has
code that imitates this behavior. With one exception: it *always* opens
the files and looks for a she-bang line *or* an `MZ` tell-tale
(nevermind that files with the magic `MZ` but without file extension
`.exe` would still not be executable).

Opening this many files leads to performance problems that are even more
serious when a virus scanner is running. Therefore, let's change the
code to look for the file extension `.exe` early, and avoid opening the
file altogether if we already know that it is executable.

See the following measurements (in seconds) as an example, where we
execute a simple program that simply lists the directory contents and
calls open() on every listed file:

With virus scanner running (coldcache):

$ ./a.exe /libexec/git-core/
before open (git-add.exe): 0.000000
after open (git-add.exe): 0.412873
before open (git-annotate.exe): 0.000175
after open (git-annotate.exe): 0.397925
before open (git-apply.exe): 0.000243
after open (git-apply.exe): 0.399996
before open (git-archive.exe): 0.000147
after open (git-archive.exe): 0.397783
before open (git-bisect--helper.exe): 0.000160
after open (git-bisect--helper.exe): 0.397700
before open (git-blame.exe): 0.000160
after open (git-blame.exe): 0.399136
...

With virus scanner running (hotcache):

$ ./a.exe /libexec/git-core/
before open (git-add.exe): 0.000000
after open (git-add.exe): 0.000325
before open (git-annotate.exe): 0.000229
after open (git-annotate.exe): 0.000177
before open (git-apply.exe): 0.000167
after open (git-apply.exe): 0.000150
before open (git-archive.exe): 0.000154
after open (git-archive.exe): 0.000156
before open (git-bisect--helper.exe): 0.000132
after open (git-bisect--helper.exe): 0.000180
before open (git-blame.exe): 0.000718
after open (git-blame.exe): 0.000724
...

With this patch I get:

$ time git help git
Launching default browser to display HTML ...

real    0m8.723s
user    0m0.000s
sys     0m0.000s

and without

$ time git help git
Launching default browser to display HTML ...

real    1m37.734s
user    0m0.000s
sys     0m0.031s

both tests with cold cache and giving the machine some time to settle
down after restart.

[jes: adjusted the commit message]

Signed-off-by: Heiko Voigt &lt;heiko.voigt@mahr.de&gt;
Signed-off-by: Johannes Schindelin &lt;johannes.schindelin@gmx.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Almost ready for 2.11.1</title>
<updated>2017-01-17T23:19:11+00:00</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2017-01-17T22:48:44+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/git.git/commit/?id=ad36dc8b4b165bf9eb3576b42a241164e312d48c'/>
<id>ad36dc8b4b165bf9eb3576b42a241164e312d48c</id>
<content type='text'>
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Merge branch 'mm/gc-safety-doc' into maint</title>
<updated>2017-01-17T23:19:11+00:00</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2017-01-17T23:19:11+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/git.git/commit/?id=647a1bcf14bd523dcca6b0be6f51f03e6863a02d'/>
<id>647a1bcf14bd523dcca6b0be6f51f03e6863a02d</id>
<content type='text'>
Doc update.

* mm/gc-safety-doc:
  git-gc.txt: expand discussion of races with other processes
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Doc update.

* mm/gc-safety-doc:
  git-gc.txt: expand discussion of races with other processes
</pre>
</div>
</content>
</entry>
<entry>
<title>Merge branch 'mm/push-social-engineering-attack-doc' into maint</title>
<updated>2017-01-17T23:19:10+00:00</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2017-01-17T23:19:10+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/git.git/commit/?id=f976c89a2028ab4661276c8ca40e003e89e01a38'/>
<id>f976c89a2028ab4661276c8ca40e003e89e01a38</id>
<content type='text'>
Doc update on fetching and pushing.

* mm/push-social-engineering-attack-doc:
  doc: mention transfer data leaks in more places
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Doc update on fetching and pushing.

* mm/push-social-engineering-attack-doc:
  doc: mention transfer data leaks in more places
</pre>
</div>
</content>
</entry>
<entry>
<title>Merge branch 'jt/fetch-no-redundant-tag-fetch-map' into maint</title>
<updated>2017-01-17T23:19:09+00:00</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2017-01-17T23:19:09+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/git.git/commit/?id=8ee6fc96f0d1800bc570568efe7d83afebd2a64c'/>
<id>8ee6fc96f0d1800bc570568efe7d83afebd2a64c</id>
<content type='text'>
Code cleanup to avoid using redundant refspecs while fetching with
the --tags option.

* jt/fetch-no-redundant-tag-fetch-map:
  fetch: do not redundantly calculate tag refmap
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Code cleanup to avoid using redundant refspecs while fetching with
the --tags option.

* jt/fetch-no-redundant-tag-fetch-map:
  fetch: do not redundantly calculate tag refmap
</pre>
</div>
</content>
</entry>
<entry>
<title>Merge branch 'ls/filter-process' into maint</title>
<updated>2017-01-17T23:19:08+00:00</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2017-01-17T23:19:08+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/git.git/commit/?id=d4a682d42f227be74c49d96eca9b86e35236f7a3'/>
<id>d4a682d42f227be74c49d96eca9b86e35236f7a3</id>
<content type='text'>
Doc update.

* ls/filter-process:
  t0021: fix flaky test
  docs: warn about possible '=' in clean/smudge filter process values
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Doc update.

* ls/filter-process:
  t0021: fix flaky test
  docs: warn about possible '=' in clean/smudge filter process values
</pre>
</div>
</content>
</entry>
<entry>
<title>Merge branch 'kh/tutorial-grammofix' into maint</title>
<updated>2017-01-17T23:19:08+00:00</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2017-01-17T23:19:08+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/git.git/commit/?id=ef6e8151335055d9a4b9067fb75f92801d4454ac'/>
<id>ef6e8151335055d9a4b9067fb75f92801d4454ac</id>
<content type='text'>
* kh/tutorial-grammofix:
  doc: omit needless "for"
  doc: make the intent of sentence clearer
  doc: add verb in front of command to run
  doc: add articles (grammar)
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
* kh/tutorial-grammofix:
  doc: omit needless "for"
  doc: make the intent of sentence clearer
  doc: add verb in front of command to run
  doc: add articles (grammar)
</pre>
</div>
</content>
</entry>
<entry>
<title>Merge branch 'lr/doc-fix-cet' into maint</title>
<updated>2017-01-17T23:19:08+00:00</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2017-01-17T23:19:07+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/git.git/commit/?id=34d5a66a611d6fc09a385ba0c847159437e0993d'/>
<id>34d5a66a611d6fc09a385ba0c847159437e0993d</id>
<content type='text'>
* lr/doc-fix-cet:
  date-formats.txt: Typo fix
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
* lr/doc-fix-cet:
  date-formats.txt: Typo fix
</pre>
</div>
</content>
</entry>
<entry>
<title>Merge branch 'sb/t3600-cleanup' into maint</title>
<updated>2017-01-17T23:19:07+00:00</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2017-01-17T23:19:06+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/git.git/commit/?id=1fb4a1126a137a032e789bb4ab2c437d281cf6c0'/>
<id>1fb4a1126a137a032e789bb4ab2c437d281cf6c0</id>
<content type='text'>
Code cleanup.

* sb/t3600-cleanup:
  t3600: slightly modernize style
  t3600: remove useless redirect
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Code cleanup.

* sb/t3600-cleanup:
  t3600: slightly modernize style
  t3600: remove useless redirect
</pre>
</div>
</content>
</entry>
<entry>
<title>Merge branch 'jk/readme-gmane-is-no-more' into maint</title>
<updated>2017-01-17T23:19:05+00:00</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2017-01-17T23:19:05+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/git.git/commit/?id=bc7547fd9206b4e463fa0f77315ec02dd445f143'/>
<id>bc7547fd9206b4e463fa0f77315ec02dd445f143</id>
<content type='text'>
* jk/readme-gmane-is-no-more:
  README: replace gmane link with public-inbox
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
* jk/readme-gmane-is-no-more:
  README: replace gmane link with public-inbox
</pre>
</div>
</content>
</entry>
</feed>
