Skip to content

Commit

Permalink
Better release build time; new maximum-performance production pro…
Browse files Browse the repository at this point in the history
…file. (#3498)

### Pull Request Description

Using the new tooling (#3491), I investigated the **performance / compile-time tradeoff** of different codegen options for release mode builds. By scripting the testing procedure, I was able to explore many possible combinations of options, which is important because their interactions (on both application performance and build time) are complex. I found **two candidate profiles** that offer specific advantages over the current `release` settings (`baseline`):
- `thin16`: Supports incremental compiles in 1/3 the time of `baseline` in common cases. Application runs about 2% slower than `baseline`.
- `fat1-O4`: Application performs 13% better than `baseline`. Compile time is almost 3x `baseline`, and non-incremental.  
(See key in first chart for the settings defining these profiles.)

We can build faster or run faster, though not in the same build. Because the effect sizes are large enough to be impactful to developer and user experience, respectively, I think we should consider having it both ways. We could **split the `release` profile** into two profiles to serve different purposes:
- `release`: A profile that supports fast developer iteration, while offering realistic performance.
- `production`: A maximally-optimized profile, for nightly builds and actual releases.

Since `wasm-pack` doesn't currently support custom profiles (rustwasm/wasm-pack#1111), we can't use a Cargo profile for `production`; however, we can implement our own profile by overriding rustc flags.

### Performance details

![perf](https://user-images.githubusercontent.com/1047859/170788530-ab6d7910-5253-4a2b-b432-8bfa0b4735ba.png)

As you can see, `thin16` is slightly slower than `baseline`; `fat1-O4` is dramatically faster.

<details>
  <summary>Methodology (click to show)</summary>

I developed a procedure for benchmarking "whole application" performance, using the new "open project" workflow (which opens the IDE and loads a complex project), and some statistical analysis to account for variance. To gather this data:

Build the application with profiling:
`./run.sh ide build --profiling-level=debug`

Run the `open_project` workflow repeatedly:
`for i in $(seq 0 9); do dist/ide/linux-unpacked/enso --entry-point profile --workflow open_project --save-profile open_project_thin16_${i}.json; done`

For each profile recorded, take the new `total_self_time` output of the `intervals` tool; gather into CSV:
`echo $(for i in $(seq 0 9); do target/rust/debug/intervals < open_project_thin16_${i}.json | tail -n1 | awk '{print $2}'; do`
(Note that the output of intervals should not be considered stable; this command may need modification in the future. Eventually it would be nice to support formatted outputs...)

The data is ready to graph. I used the `boxplot` method of the [seaborn](https://seaborn.pydata.org/index.html) package, in order to show the distribution of data.
</details>

#### Build times
![thin16](https://user-images.githubusercontent.com/1047859/170788539-1578e41b-bc30-4f30-9b71-0b0181322fa5.png)

In the case of changing a file in `enso-prelude`, with the current `baseline` settings rebuilding takes over 3 minutes. With the `thin16` settings, the same rebuild completes in 40 seconds.

(To gather this data on different hardware or in the future, just run the new `bench-build.sh` script for each case to be measured.)
  • Loading branch information
kazcw authored Jun 10, 2022
1 parent e97d27e commit a1bf097
Show file tree
Hide file tree
Showing 7 changed files with 244 additions and 83 deletions.
198 changes: 178 additions & 20 deletions .github/workflows/gui.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,22 @@ jobs:
with:
clean: false
- run: "./run --help"
if: "runner.os == 'Windows'"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
shell: pwsh
- run: "./run --help"
if: "runner.os != 'Windows'"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
shell: bash
- run: "./run project-manager"
- run: "./run backend get"
if: "runner.os == 'Windows'"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
shell: pwsh
- run: "./run backend get"
if: "runner.os != 'Windows'"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
shell: bash
Expand Down Expand Up @@ -86,10 +98,22 @@ jobs:
with:
clean: false
- run: "./run --help"
if: "runner.os == 'Windows'"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
shell: pwsh
- run: "./run --help"
if: "runner.os != 'Windows'"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
shell: bash
- run: "./run project-manager"
- run: "./run backend get"
if: "runner.os == 'Windows'"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
shell: pwsh
- run: "./run backend get"
if: "runner.os != 'Windows'"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
shell: bash
Expand Down Expand Up @@ -122,14 +146,26 @@ jobs:
uses: actions/checkout@v3
with:
clean: false
- run: ".\\run.cmd --help"
- run: "./run --help"
if: "runner.os == 'Windows'"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
shell: cmd
- run: ".\\run.cmd project-manager"
shell: pwsh
- run: "./run --help"
if: "runner.os != 'Windows'"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
shell: bash
- run: "./run backend get"
if: "runner.os == 'Windows'"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
shell: pwsh
- run: "./run backend get"
if: "runner.os != 'Windows'"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
shell: cmd
shell: bash
- name: List files if failed
run: ls -R
if: failure()
Expand Down Expand Up @@ -160,10 +196,22 @@ jobs:
with:
clean: false
- run: "./run --help"
if: "runner.os == 'Windows'"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
shell: pwsh
- run: "./run --help"
if: "runner.os != 'Windows'"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
shell: bash
- run: "./run wasm build"
if: "runner.os == 'Windows'"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
shell: pwsh
- run: "./run wasm build"
if: "runner.os != 'Windows'"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
shell: bash
Expand Down Expand Up @@ -195,10 +243,22 @@ jobs:
with:
clean: false
- run: "./run --help"
if: "runner.os == 'Windows'"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
shell: pwsh
- run: "./run --help"
if: "runner.os != 'Windows'"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
shell: bash
- run: "./run wasm build"
if: "runner.os == 'Windows'"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
shell: pwsh
- run: "./run wasm build"
if: "runner.os != 'Windows'"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
shell: bash
Expand Down Expand Up @@ -231,14 +291,26 @@ jobs:
uses: actions/checkout@v3
with:
clean: false
- run: ".\\run.cmd --help"
- run: "./run --help"
if: "runner.os == 'Windows'"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
shell: pwsh
- run: "./run --help"
if: "runner.os != 'Windows'"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
shell: bash
- run: "./run wasm build"
if: "runner.os == 'Windows'"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
shell: cmd
- run: ".\\run.cmd wasm build"
shell: pwsh
- run: "./run wasm build"
if: "runner.os != 'Windows'"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
shell: cmd
shell: bash
- name: List files if failed
run: ls -R
if: failure()
Expand Down Expand Up @@ -280,10 +352,22 @@ jobs:
with:
clean: false
- run: "./run --help"
if: "runner.os == 'Windows'"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
shell: pwsh
- run: "./run --help"
if: "runner.os != 'Windows'"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
shell: bash
- run: "./run ide integration-test --project-manager-source current-ci-run"
- run: "./run ide integration-test --backend-source current-ci-run"
if: "runner.os == 'Windows'"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
shell: pwsh
- run: "./run ide integration-test --backend-source current-ci-run"
if: "runner.os != 'Windows'"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
shell: bash
Expand Down Expand Up @@ -317,10 +401,22 @@ jobs:
with:
clean: false
- run: "./run --help"
if: "runner.os == 'Windows'"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
shell: pwsh
- run: "./run --help"
if: "runner.os != 'Windows'"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
shell: bash
- run: "./run lint"
if: "runner.os == 'Windows'"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
shell: pwsh
- run: "./run lint"
if: "runner.os != 'Windows'"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
shell: bash
Expand Down Expand Up @@ -354,10 +450,22 @@ jobs:
with:
clean: false
- run: "./run --help"
if: "runner.os == 'Windows'"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
shell: pwsh
- run: "./run --help"
if: "runner.os != 'Windows'"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
shell: bash
- run: "./run wasm test --no-wasm"
if: "runner.os == 'Windows'"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
shell: pwsh
- run: "./run wasm test --no-wasm"
if: "runner.os != 'Windows'"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
shell: bash
Expand All @@ -367,8 +475,8 @@ jobs:
ide-ci-actions-workflow-definition-job-package-ide-linux:
name: Package IDE (linux)
needs:
- ide-ci-actions-workflow-definition-job-build-wasm-linux
- ide-ci-actions-workflow-definition-job-build-project-manager-linux
- ide-ci-actions-workflow-definition-job-build-wasm-linux
runs-on:
- self-hosted
- Linux
Expand All @@ -394,10 +502,22 @@ jobs:
with:
clean: false
- run: "./run --help"
if: "runner.os == 'Windows'"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
shell: pwsh
- run: "./run --help"
if: "runner.os != 'Windows'"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
shell: bash
- run: "./run ide build --wasm-source current-ci-run --project-manager-source current-ci-run"
- run: "./run ide build --wasm-source current-ci-run --backend-source current-ci-run"
if: "runner.os == 'Windows'"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
shell: pwsh
- run: "./run ide build --wasm-source current-ci-run --backend-source current-ci-run"
if: "runner.os != 'Windows'"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
shell: bash
Expand All @@ -407,8 +527,8 @@ jobs:
ide-ci-actions-workflow-definition-job-package-ide-macos:
name: Package IDE (macos)
needs:
- ide-ci-actions-workflow-definition-job-build-wasm-macos
- ide-ci-actions-workflow-definition-job-build-project-manager-macos
- ide-ci-actions-workflow-definition-job-build-wasm-macos
runs-on:
- macos-latest
steps:
Expand All @@ -432,10 +552,22 @@ jobs:
with:
clean: false
- run: "./run --help"
if: "runner.os == 'Windows'"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
shell: pwsh
- run: "./run --help"
if: "runner.os != 'Windows'"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
shell: bash
- run: "./run ide build --wasm-source current-ci-run --project-manager-source current-ci-run"
- run: "./run ide build --wasm-source current-ci-run --backend-source current-ci-run"
if: "runner.os == 'Windows'"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
shell: pwsh
- run: "./run ide build --wasm-source current-ci-run --backend-source current-ci-run"
if: "runner.os != 'Windows'"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
shell: bash
Expand All @@ -445,8 +577,8 @@ jobs:
ide-ci-actions-workflow-definition-job-package-ide-windows:
name: Package IDE (windows)
needs:
- ide-ci-actions-workflow-definition-job-build-wasm-windows
- ide-ci-actions-workflow-definition-job-build-project-manager-windows
- ide-ci-actions-workflow-definition-job-build-wasm-windows
runs-on:
- self-hosted
- Windows
Expand All @@ -471,14 +603,26 @@ jobs:
uses: actions/checkout@v3
with:
clean: false
- run: ".\\run.cmd --help"
- run: "./run --help"
if: "runner.os == 'Windows'"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
shell: cmd
- run: ".\\run.cmd ide build --wasm-source current-ci-run --project-manager-source current-ci-run"
shell: pwsh
- run: "./run --help"
if: "runner.os != 'Windows'"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
shell: cmd
shell: bash
- run: "./run ide build --wasm-source current-ci-run --backend-source current-ci-run"
if: "runner.os == 'Windows'"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
shell: pwsh
- run: "./run ide build --wasm-source current-ci-run --backend-source current-ci-run"
if: "runner.os != 'Windows'"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
shell: bash
- name: List files if failed
run: ls -R
if: failure()
Expand Down Expand Up @@ -509,13 +653,27 @@ jobs:
with:
clean: false
- run: "./run --help"
if: "runner.os == 'Windows'"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
shell: pwsh
- run: "./run --help"
if: "runner.os != 'Windows'"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
shell: bash
- run: "./run wasm test --no-native"
if: "runner.os == 'Windows'"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
shell: pwsh
- run: "./run wasm test --no-native"
if: "runner.os != 'Windows'"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
shell: bash
- name: List files if failed
run: ls -R
if: failure()
env:
ENSO_BUILD_SKIP_VERSION_CHECK: "true"
Loading

0 comments on commit a1bf097

Please sign in to comment.