[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] externals/caml 4c8c8d3 176/197: makefiles: use 'install' instea
From: |
Stefan Monnier |
Subject: |
[nongnu] externals/caml 4c8c8d3 176/197: makefiles: use 'install' instead of 'cp' in 'make install' targets |
Date: |
Sat, 21 Nov 2020 01:20:02 -0500 (EST) |
branch: externals/caml
commit 4c8c8d3c8e0faa9361f87087dbd278b2fcb46abc
Author: Gabriel Scherer <gabriel.scherer@gmail.com>
Commit: Gabriel Scherer <gabriel.scherer@gmail.com>
makefiles: use 'install' instead of 'cp' in 'make install' targets
I can observe weird performance bottlenecks on my machine caused by
the use of 'cp' in the 'install' scripts of OCaml. When installing
into a directory that is already populated by an existing
installation, 'make install' can routinely take 10s on my machine¹. After
this
change it reliably takes 1.5s, independently of whether the
destination is already populated or not.
¹: a brtfs filesystem on an old-ish SSD
Why I care
----------
An extra 10s delay due to 'make install' can be noticeable in tight
change-build-install-test feedback loops for a compiler change where
we change the compiler, have a fast 'make world.opt' due to
incremental builds, install the change and test it -- possibly after
installing a couple opam packages, which can be fairly quick.
Partial diagnosis
-----------------
The performance issue seems to be caused by the fact that 'cp' (at
least the GNU coreutils version), when the file already exists,
replaces it by opening it in writeonly+truncate mode and writing the
file content ('strace' shows that the delay is caused within an
'openat' call). In particular, using the --remove-destination option
(which changes 'cp' to just remove the destination file before
copying) removes the performance issue, but this option seems missing
from the BSD/OSX 'cp' so it could cause portability issue.
Change
------
The present commit rewrites the 'install' targets of all Makefiles to
use the 'install' command instead. 'install' by default gives
executable-like permission to the destination file, instead of reusing
the source file's permissions, so we specify manually the permission
modes, depending on whether the installed file is an executable (or
dynamically-linked library) or just data (including other compiled
object files).
Testing
-------
I checked manually that the permissions of the installed files are
identical to the ones of the current 'cp'-using targets, except for
some '.mli' file in middle_end which currently have +x bits enabled
for no good reason.
Remark: To test this, playing with the DESTDIR variable is very useful
(this lets you install to a new directory (or the same as before)
without having to re-run the configure script). I used the following,
fairly slow shell script to collect permissions:
for f in $(find $DESTDIR); do \
echo $(basename $f) $(ls -l $f | cut -d' ' -f1); \
done | sort
Remark: it is important to run `sync` in-between 'make install' runs
to avoid timing effects due to filesystem or disk caching
strategies. I believe that this corresponds to the natural time delay
(and unrelated disk activity) that would occur in realistic
change-install-test feedback loops.
---
Makefile | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/Makefile b/Makefile
index 93b2d7d..fd48e8c 100644
--- a/Makefile
+++ b/Makefile
@@ -40,6 +40,9 @@ COMPILECMD=(progn \
(byte-compile-file "caml-font.el") \
(byte-compile-file "camldebug.el"))
+MDATA=u+rw,g+rw,o+r
+MPROG=u+rwx,g+rwx,o+rx
+
install:
@if test "$(EMACSDIR)" = ""; then \
$(EMACS) --batch --eval 't; see PR#5403'; \
@@ -64,7 +67,7 @@ install-el:
simple-install:
@echo "Installing in $(EMACSDIR)..."
if test -d $(EMACSDIR); then : ; else mkdir -p $(EMACSDIR); fi
- cp $(FILES) $(EMACSDIR)
+ install -m $(MDATA) $(FILES) $(EMACSDIR)
if [ -z "$(NOCOMPILE)" ]; then \
cd $(EMACSDIR); $(EMACS) --batch --eval '$(COMPILECMD)'; \
fi
@@ -74,7 +77,7 @@ ocamltags: ocamltags.in
chmod a+x ocamltags
install-ocamltags: ocamltags
- cp ocamltags $(SCRIPTDIR)/ocamltags
+ install -m $(MDATA) ocamltags $(SCRIPTDIR)/ocamltags
# This is for testing purposes
compile-only:
- [nongnu] externals/caml 633a39e 161/197: Update headers for the new license., (continued)
- [nongnu] externals/caml 633a39e 161/197: Update headers for the new license., Stefan Monnier, 2020/11/21
- [nongnu] externals/caml b499b25 171/197: MPR#7610: caml.el: avoid using deprecated last-command-char variable, Stefan Monnier, 2020/11/21
- [nongnu] externals/caml b2088ca 158/197: GPR#243: Faster test suite, Stefan Monnier, 2020/11/21
- [nongnu] externals/caml a913400 175/197: elisp: cosmetic docstring tweaks, Stefan Monnier, 2020/11/21
- [nongnu] externals/caml c0bf206 169/197: Follow Emacs Lisp conventions for caml.el (#1346), Stefan Monnier, 2020/11/21
- [nongnu] externals/caml f49a296 164/197: caml-types.el: Extract the feedback logic to a separate function., Stefan Monnier, 2020/11/21
- [nongnu] externals/caml 4c414a0 180/197: Emacs: Improve colors on dark themes, Stefan Monnier, 2020/11/21
- [nongnu] externals/caml 07d301a 174/197: elisp: fixed grammar in docstrings and comments, Stefan Monnier, 2020/11/21
- [nongnu] externals/caml 2964c4d 162/197: Add another format to parse compiler output., Stefan Monnier, 2020/11/21
- [nongnu] externals/caml 02f8809 184/197: Emacs: use symbol boundaries in regular expressions, Stefan Monnier, 2020/11/21
- [nongnu] externals/caml 4c8c8d3 176/197: makefiles: use 'install' instead of 'cp' in 'make install' targets,
Stefan Monnier <=
- [nongnu] externals/caml c9e7f57 186/197: Fix most CheckDoc errors., Stefan Monnier, 2020/11/21
- [nongnu] externals/caml 78ec6be 185/197: Transform the README to Markdown, Stefan Monnier, 2020/11/21
- [nongnu] externals/caml 333d2f4 191/197: Improve syntax highlighting, Stefan Monnier, 2020/11/21
- [nongnu] externals/caml adafe8a 190/197: Add OPAM file, Stefan Monnier, 2020/11/21
- [nongnu] externals/caml 466d703 194/197: Minor improvements to the README, Stefan Monnier, 2020/11/21
- [nongnu] externals/caml 1d6cd46 196/197: Add make target for opam release, Stefan Monnier, 2020/11/21
- [nongnu] externals/caml 38ebde1 197/197: Generate a caml-mode-site-file, Stefan Monnier, 2020/11/21
- [nongnu] externals/caml 29aaf70 193/197: Move the changelog to CHANGES, Stefan Monnier, 2020/11/21
- [nongnu] externals/caml bfa612b 195/197: Mention easy ways of installing this package, Stefan Monnier, 2020/11/21
- [nongnu] externals/caml b6eebe4 192/197: Apply some recommendations of checkdoc, Stefan Monnier, 2020/11/21