Skip to content

Commit

Permalink
CP-51479: Optimize 'make install' (#5982)
Browse files Browse the repository at this point in the history
We spend quite a lot of time here because dune is invoked multiple times
from different makefile rules, also install.sh was very verbose.

Draft PR to check github CI.

Running `make build install` with no changes to the code is ~3x faster
now:
```
Benchmark 1: rm /tmp/install/1 -rf; make -C ../scm-master build install DESTDIR=/tmp/install/1
  Time (mean ± σ):     20.575 s ±  0.239 s    [User: 13.093 s, System: 9.113 s]
  Range (min … max):   20.356 s … 21.064 s    10 runs

Benchmark 2: rm /tmp/install/2 -rf; make build install DESTDIR=/tmp/install/2
  Time (mean ± σ):      6.355 s ±  0.954 s    [User: 7.489 s, System: 5.320 s]
  Range (min … max):    5.827 s …  9.040 s    10 runs

Summary
  rm /tmp/install/2 -rf; make build install DESTDIR=/tmp/install/2 ran
    3.24 ± 0.49 times faster than rm /tmp/install/1 -rf; make -C ../scm-master build install DESTDIR=/tmp/install/1
```

20s for a noop incremental build was too slow, 6s is still slow, but
better.

And running just `make install` when there are no changes is about ~7x
faster now:
```
Benchmark 1: rm /tmp/install/2 -rf; make install DESTDIR=/tmp/install/2
  Time (mean ± σ):      2.791 s ±  0.075 s    [User: 4.469 s, System: 4.640 s]
  Range (min … max):    2.591 s …  2.863 s    10 runs
```

Koji build times are slightly improved too (~3m44s for buildArch phase
vs ~4m06s).

There are some changes in file permissions, but they look OK (e.g.
having execute permissions on the manpages was wrong to begin with):

<details>
<summary> Permission changes </summary>
```
--- refs	2024-09-16 09:24:17.408911755 +0100
+++ thiss	2024-09-16 09:24:17.415912441 +0100
@@ -1404,7 +1404,7 @@
 ./opt/xensource/bin/rrd2csv -rwxr-xr-x
 ./opt/xensource/bin/static-vdis -rwxr-xr-x
 ./opt/xensource/bin/update-ca-bundle.sh -rwxr-xr-x
-./opt/xensource/bin/xapi -r-xr-xr-x
+./opt/xensource/bin/xapi -rwxr-xr-x
 ./opt/xensource/bin/xapi-autostart-vms -rwxr-xr-x
 ./opt/xensource/bin/xapi-db-process -rwxr-xr-x
 ./opt/xensource/bin/xapi-wait-init-complete -rwxr-xr-x
@@ -1422,13 +1422,13 @@
 ./opt/xensource/bin/xe-switch-network-backend -rwxr-xr-x
 ./opt/xensource/bin/xe-toolstack-restart -rwxr-xr-x
 ./opt/xensource/bin/xe-xentrace -rwxr-xr-x
-./opt/xensource/bin/xsh -r-xr-xr-x
+./opt/xensource/bin/xsh -rwxr-xr-x
 ./opt/xensource/debug/debug_ha_query_liveset -rwxr-xr-x
 ./opt/xensource/debug/event_listen -rwxr-xr-x
 ./opt/xensource/debug/import-update-key -rwxr-xr-x
 ./opt/xensource/debug/perftest -rwxr-xr-x
 ./opt/xensource/debug/quicktest -rwxr-xr-x
-./opt/xensource/debug/quicktestbin -r-xr-xr-x
+./opt/xensource/debug/quicktestbin -rwxr-xr-x
 ./opt/xensource/debug/rbac_static.csv -rw-r--r--
 ./opt/xensource/debug/suspend-image-viewer -rwxr-xr-x
 ./opt/xensource/debug/vncproxy -rwxr-xr-x
@@ -1459,7 +1459,7 @@
 ./opt/xensource/libexec/network-init -rwxr-xr-x
 ./opt/xensource/libexec/pbis-force-domain-leave -rwxr-xr-x
 ./opt/xensource/libexec/print-custom-templates -rwxr-xr-x
-./opt/xensource/libexec/python_nbd_client.py -rw-r--r--
+./opt/xensource/libexec/python_nbd_client.py -rwxr-xr-x
 ./opt/xensource/libexec/reset-and-reboot -rwxr-xr-x
 ./opt/xensource/libexec/restore-sr-metadata.py -rwxr-xr-x
 ./opt/xensource/libexec/save-boot-info -rwxr-xr-x
@@ -1705,9 +1705,9 @@
 ./usr/sbin/xenopsd-simulator -rwxr-xr-x
 ./usr/sbin/xenopsd-xc -rwxr-xr-x
 ./usr/share/man/man1/xcp-networkd.1 -rw-r--r--
-./usr/share/man/man1/xenops-cli.1.gz -rwxr-xr-x
-./usr/share/man/man1/xenopsd-simulator.1.gz -rwxr-xr-x
-./usr/share/man/man1/xenopsd-xc.1.gz -rwxr-xr-x
+./usr/share/man/man1/xenops-cli.1.gz -rw-r--r--
+./usr/share/man/man1/xenopsd-simulator.1.gz -rw-r--r--
+./usr/share/man/man1/xenopsd-xc.1.gz -rw-r--r--
 ./usr/share/man/man8/xapi-storage-script.8 -rw-r--r--
 ./usr/share/xapi/doc/classes.dot -rw-r--r--
 ./usr/share/xapi/doc/doc-convert.sh -rwxr-xr-x
@@ -2034,7 +2034,7 @@
 ./usr/share/xapi/doc/markdown/class-vtpm.md -rw-r--r--
 ./usr/share/xapi/doc/markdown/class-vusb.md -rw-r--r--
 ./usr/share/xapi/doc/markdown/classes.md -rw-r--r--
-./usr/share/xapi/doc/markdown/management-api.md -r--r--r--
+./usr/share/xapi/doc/markdown/management-api.md -rw-r--r--
 ./usr/share/xapi/doc/markdown/relationships-between-classes.md -rw-r--r--
 ./usr/share/xapi/doc/markdown/toc.yml -rw-r--r--
 ./usr/share/xapi/doc/markdown/types.md -rw-r--r--
```

</details>
  • Loading branch information
edwintorok authored Oct 1, 2024
2 parents 15721af + 48f12a7 commit 9e1ea63
Show file tree
Hide file tree
Showing 191 changed files with 1,843 additions and 1,225 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/generate-and-build-sdks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,34 +32,34 @@ jobs:
with:
name: SDK_Source_C
path: |
_build/install/default/xapi/sdk/c/*
!_build/install/default/xapi/sdk/c/dune
_build/install/default/share/c/*
!_build/install/default/share/c/dune
- name: Store C# SDK source
uses: actions/upload-artifact@v4
with:
name: SDK_Source_CSharp
path: _build/install/default/xapi/sdk/csharp/*
path: _build/install/default/share/csharp/*

- name: Store PowerShell SDK source
uses: actions/upload-artifact@v4
with:
name: SDK_Source_PowerShell
path: _build/install/default/xapi/sdk/powershell/*
path: _build/install/default/share/powershell/*

- name: Store Go SDK Artifacts
uses: actions/upload-artifact@v4
with:
name: SDK_Artifacts_Go
path: |
_build/install/default/xapi/sdk/go/*
!_build/install/default/xapi/sdk/go/dune
_build/install/default/share/go/*
!_build/install/default/share/go/dune
- name: Store Java SDK source
uses: actions/upload-artifact@v4
with:
name: SDK_Source_Java
path: _build/install/default/xapi/sdk/java/*
path: _build/install/default/share/java/*

- name: Trim dune cache
run: opam exec -- dune cache trim --size=2GiB
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/go-ci/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ runs:
uses: golangci/golangci-lint-action@v4
with:
version: v1.57.2
working-directory: ${{ github.workspace }}/_build/install/default/xapi/sdk/go/src
working-directory: ${{ github.workspace }}/_build/install/default/share/go/src
args: --config=${{ github.workspace }}/.golangci.yml

- name: Run CI for Go SDK
shell: bash
run: |
cd ./ocaml/sdk-gen/component-test/
cp -r ${{ github.workspace }}/_build/install/default/xapi/sdk/go/src jsonrpc-client/go/goSDK
bash run-tests.sh
cp -r ${{ github.workspace }}/_build/install/default/share/go/src jsonrpc-client/go/goSDK
bash run-tests.sh
2 changes: 1 addition & 1 deletion .github/workflows/sdk-ci/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ runs:
- name: Run CI for Go SDK
uses: ./.github/workflows/go-ci

# Run other tests here
# Run other tests here
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,13 @@ python3/examples/XenAPI.egg-info/
python3/examples/build/
python3/examples/dist/

# ignore file needed for building the SDK
ocaml/sdk-gen/csharp/XE_SR_ERRORCODES.xml

# configure-generated files
ocaml/xenopsd/scripts/vif
ocaml/xenopsd/scripts/xen-backend.rules
ocaml/xenopsd/xentoollog_flags

ocaml/idl/gen_lifecycle.exe
ocaml/idl/api_version.ml.in2

# hugo
.hugo_build.lock
Expand Down
231 changes: 70 additions & 161 deletions Makefile

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions clock.opam
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ depends: [
"ocaml" {>= "4.12"}
"alcotest" {with-test}
"astring"
"fmt"
"mtime"
"ptime"
"xapi-log" {= version}
Expand Down
2 changes: 1 addition & 1 deletion cohttp-posix.opam
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ build: [[ "dune" "build" "-p" name "-j" jobs ]]
available: [ os = "linux" ]
depends: [
"ocaml"
"dune"
"dune" {>= "3.15"}
"cohttp"
]
synopsis: "Library required by xapi"
Expand Down
2 changes: 1 addition & 1 deletion cohttp-posix.opam.template
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ build: [[ "dune" "build" "-p" name "-j" jobs ]]
available: [ os = "linux" ]
depends: [
"ocaml"
"dune"
"dune" {>= "3.15"}
"cohttp"
]
synopsis: "Library required by xapi"
Expand Down
6 changes: 6 additions & 0 deletions dune
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,9 @@
; Can still be used for dependencies, but dune won't scan these dirs
; for dune files
(data_only_dirs doc scripts python3 .vscode)

(install
(package xapi-sdk)
(section share_root)
(files (python3/examples/XenAPI/XenAPI.py as python/XenAPI.py))
)
Loading

0 comments on commit 9e1ea63

Please sign in to comment.