Skip to content

Commit

Permalink
Tweak cargo compilation profiles.
Browse files Browse the repository at this point in the history
Previously, `cargo test` was pretty slow to compile because it was being
optimised at level 2. This commit optimises at level 0, so it's much faster to
compile, but the tests take a bit longer to complete. Just test what you need
to, I guess.

Also add a "production" profile, for maximum performance.

Adjust the CI scripts to test with optimisation, because the tests would
otherwise take an extremely long time.
  • Loading branch information
cjordan committed Sep 23, 2023
1 parent 1c80f90 commit 8f6bb41
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ jobs:
- name: Generate test lcov coverage into coverage/ dir
run: |
export MWA_BEAM_FILE=$(realpath mwa_full_embedded_element_pattern.h5)
cargo llvm-cov --workspace --lcov --output-path lcov.info
cargo llvm-cov --workspace --release --lcov --output-path lcov.info
- name: Upload reports to codecov.io
uses: codecov/codecov-action@v3
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/releases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,20 @@ jobs:
curl https://heasarc.gsfc.nasa.gov/FTP/software/fitsio/c/License.txt -o LICENSE-cfitsio
cp .github/workflows/releases-readme.md README.md
cargo build --release --locked --no-default-features --features=hdf5-static,erfa-static,cfitsio-static
mv target/release/hyperdrive .
cargo build --profile production --locked --no-default-features --features=hdf5-static,erfa-static,cfitsio-static
mv target/production/hyperdrive .
tar -acvf mwa_hyperdrive-$(git describe --tags)-Linux-x86-64-v3.tar.gz \
LICENSE COPYING-hdf5 LICENSE-erfa LICENSE-cfitsio README.md \
hyperdrive
cargo build --release --locked --no-default-features --features=hdf5-static,erfa-static,cfitsio-static,cuda
mv target/release/hyperdrive .
cargo build --profile production --locked --no-default-features --features=hdf5-static,erfa-static,cfitsio-static,cuda
mv target/production/hyperdrive .
tar -acvf mwa_hyperdrive-$(git describe --tags)-Linux-x86-64-v3-CUDA-double.tar.gz \
LICENSE COPYING-hdf5 LICENSE-erfa LICENSE-cfitsio LICENSE-NVIDIA README.md \
hyperdrive
cargo build --release --locked --no-default-features --features=hdf5-static,erfa-static,cfitsio-static,cuda-single
mv target/release/hyperdrive .
cargo build --profile production --locked --no-default-features --features=hdf5-static,erfa-static,cfitsio-static,cuda-single
mv target/production/hyperdrive .
tar -acvf mwa_hyperdrive-$(git describe --tags)-Linux-x86-64-v3-CUDA-single.tar.gz \
LICENSE COPYING-hdf5 LICENSE-erfa LICENSE-cfitsio LICENSE-NVIDIA README.md \
hyperdrive
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,17 @@ jobs:
# Test that building works. Build statically first so less compiling is
# needed when running tests.
- name: Debug build with static features
run: cargo test --locked --features=cuda,all-static --no-run
run: cargo test --locked --release --features=cuda,all-static --no-run

- name: Debug build
run: cargo test --locked --features=cuda --no-run
run: cargo test --locked --release --features=cuda --no-run

# Can't test with CUDA, no GPUs available in CI
- name: Run tests
run: cargo test --locked
run: cargo test --locked --release

- name: Run ignored tests
run: cargo test --locked -- --ignored
run: cargo test --locked --release -- --ignored

- name: Minimum-specified Rust version works
run: |
Expand Down
9 changes: 7 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,15 @@ exclude = [".github/*", "test_files/*"]

[profile.release]
panic = "abort"
codegen-units = 256

[profile.production]
inherits = "release"
lto = "thin"
codegen-units = 1

[profile.dev]
opt-level = 2
[profile.bench]
inherits = "production"

[features]
default = ["plotting"]
Expand Down
23 changes: 10 additions & 13 deletions mdbook/src/installation/from_source.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,28 +78,25 @@ cargo install mwa_hyperdrive --locked

If you want to download the source code and install it yourself, read on.

## Cloning the `hyperdrive` repo
## Manually installing from the `hyperdrive` repo

```shell
git clone https://github.com/MWATelescope/mwa_hyperdrive
```

Don't forget to `cd` into the repo:
Clone the git repo and point `cargo` to it:

```shell
cd mwa_hyperdrive
```

## Compiling `hyperdrive`

```shell
cargo install --path . --locked
git clone https://github.com/MWATelescope/mwa_hyperdrive
cargo install --path mwa_hyperdrive --locked
```

This will install `hyperdrive` to `~/.cargo/bin/hyperdrive`. This binary can be
moved anywhere and it will still work. The installation destination can be
changed by setting `CARGO_HOME`.

~~~admonish danger title="Further optimisation"
It is possible to compile with more optimisations if you give `--profile
production` to the `cargo install` command. This may make things a few percent
faster, but compilation will take much longer.
~~~

~~~admonish danger title="CUDA"
Do you have a CUDA-capable NVIDIA GPU? Ensure you have installed
[CUDA](https://developer.nvidia.com/cuda-zone) (instructions are above), find
Expand Down

0 comments on commit 8f6bb41

Please sign in to comment.