generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 129
Introduce compiler timing script & CI job #4154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
carolynzech
merged 13 commits into
model-checking:main
from
AlexanderPortland:compiler-timing-ci
Jun 24, 2025
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
9c857e6
add option to print compiler timing info
AlexanderPortland 23721da
introduce compile-timer profiling tool
AlexanderPortland 725803b
introduce compile-analyzer comparison tool
AlexanderPortland f0a36d8
add new CI workflow for running compiler timing
AlexanderPortland 308c449
reorganize bench labels & workflows
AlexanderPortland 4e35bc2
fix parsing bug in timer & add more options
AlexanderPortland 44c4021
make benchcomp output collapsible
AlexanderPortland 917df2a
add long compiler timing CI job
AlexanderPortland 1b6f1dc
fix markdown table-rendering issue
AlexanderPortland f8f06e4
update signficance thresholds
AlexanderPortland c8af69a
fix percent change calculation bug
AlexanderPortland 78f216f
fix minor compile-timer feedback
AlexanderPortland dee3f1c
fix minor workflow feedback
AlexanderPortland File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,140 @@ | ||
| # Copyright Kani Contributors | ||
| # SPDX-License-Identifier: Apache-2.0 OR MIT | ||
| # | ||
| # Run performance benchmarks comparing the compiler performance of two different Kani versions. | ||
| name: Kani Compiler Performance Benchmarks | ||
| on: | ||
| push: | ||
| branches: | ||
| - 'main' | ||
| workflow_call: | ||
|
|
||
| jobs: | ||
| compile-timer-short: | ||
| runs-on: ubuntu-24.04 | ||
| steps: | ||
| - name: Save push event HEAD and HEAD~ to environment variables | ||
| if: ${{ github.event_name == 'push' }} | ||
| run: | | ||
| echo "NEW_REF=${{ github.event.after}}" | tee -a "$GITHUB_ENV" | ||
| echo "OLD_REF=${{ github.event.before }}" | tee -a "$GITHUB_ENV" | ||
| - name: Save pull request HEAD and base to environment variables | ||
| if: ${{ contains(fromJSON('["pull_request", "pull_request_target"]'), github.event_name) }} | ||
| run: | | ||
| echo "OLD_REF=${{ github.event.pull_request.base.sha }}" | tee -a "$GITHUB_ENV" | ||
| echo "NEW_REF=${{ github.event.pull_request.head.sha }}" | tee -a "$GITHUB_ENV" | ||
| - name: Check out Kani (old variant) | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| path: ./old | ||
| ref: ${{ env.OLD_REF }} | ||
| fetch-depth: 2 | ||
|
|
||
| - name: Check out Kani (new variant) | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| path: ./new | ||
| ref: ${{ env.NEW_REF }} | ||
| fetch-depth: 1 | ||
|
|
||
| - name: Set up Kani Dependencies (old variant) | ||
| uses: ./old/.github/actions/setup | ||
| with: | ||
| os: ubuntu-24.04 | ||
| kani_dir: old | ||
|
|
||
| - name: Set up Kani Dependencies (new variant) | ||
| uses: ./new/.github/actions/setup | ||
| with: | ||
| os: ubuntu-24.04 | ||
| kani_dir: new | ||
|
|
||
| - name: Copy benchmarks from new to old | ||
| run: rm -rf ./old/tests/perf ; cp -r ./new/tests/perf ./old/tests/ | ||
AlexanderPortland marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| - name: Build `compile-timer` in old | ||
| run: cd old/tools/compile-timer && cargo build --release | ||
| - name: Build `kani` in old | ||
| run: cd old && cargo build-dev --release | ||
|
|
||
| - name: Build `compile-timer` in new | ||
| run: cd new/tools/compile-timer && cargo build --release | ||
| - name: Build `kani` in new | ||
| run: cd new && cargo build-dev --release | ||
|
|
||
| - name: Run `compile-timer` on old | ||
| run: | | ||
| export PATH="${{ github.workspace }}/old/scripts:$PATH" | ||
| cd old/tests/perf && ../../target/release/compile-timer --out-path compile-times-old.json --ignore kani-lib --ignore display_trait --ignore s2n-quic | ||
| - name: Run `compile-timer` on new | ||
| run: | | ||
| export PATH="${{ github.workspace }}/new/scripts:$PATH" | ||
| cd new/tests/perf && ../../target/release/compile-timer --out-path compile-times-new.json --ignore kani-lib --ignore display_trait --ignore s2n-quic | ||
| - name: Run analysis between the two | ||
| run: ./new/target/release/compile-analyzer --path-pre old/tests/perf/compile-times-old.json --path-post new/tests/perf/compile-times-new.json --only-markdown --suite-name short >> "$GITHUB_STEP_SUMMARY" | ||
|
|
||
| compile-timer-long: | ||
| runs-on: ubuntu-24.04 | ||
| steps: | ||
| - name: Save push event HEAD and HEAD~ to environment variables | ||
| if: ${{ github.event_name == 'push' }} | ||
| run: | | ||
| echo "NEW_REF=${{ github.event.after}}" | tee -a "$GITHUB_ENV" | ||
| echo "OLD_REF=${{ github.event.before }}" | tee -a "$GITHUB_ENV" | ||
| - name: Save pull request HEAD and base to environment variables | ||
| if: ${{ contains(fromJSON('["pull_request", "pull_request_target"]'), github.event_name) }} | ||
| run: | | ||
| echo "OLD_REF=${{ github.event.pull_request.base.sha }}" | tee -a "$GITHUB_ENV" | ||
| echo "NEW_REF=${{ github.event.pull_request.head.sha }}" | tee -a "$GITHUB_ENV" | ||
|
|
||
| - name: Check out Kani (old variant) | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| path: ./old | ||
| ref: ${{ env.OLD_REF }} | ||
| fetch-depth: 2 | ||
|
|
||
| - name: Check out Kani (new variant) | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| path: ./new | ||
| ref: ${{ env.NEW_REF }} | ||
| fetch-depth: 1 | ||
|
|
||
| - name: Set up Kani Dependencies (old variant) | ||
| uses: ./old/.github/actions/setup | ||
| with: | ||
| os: ubuntu-24.04 | ||
| kani_dir: old | ||
|
|
||
| - name: Set up Kani Dependencies (new variant) | ||
| uses: ./new/.github/actions/setup | ||
| with: | ||
| os: ubuntu-24.04 | ||
| kani_dir: new | ||
|
|
||
| # Ensures that a PR changing the benchmarks will have the new benchmarks run | ||
| # for both commits. | ||
| - name: Copy benchmarks from new to old | ||
| run: rm -rf ./old/tests/perf ; cp -r ./new/tests/perf ./old/tests/ | ||
|
|
||
| - name: Build `compile-timer` in old | ||
| run: cd old/tools/compile-timer && cargo build --release | ||
| - name: Build `kani` in old | ||
| run: cd old && cargo build-dev --release | ||
|
|
||
| - name: Build `compile-timer` in new | ||
| run: cd new/tools/compile-timer && cargo build --release | ||
| - name: Build `kani` in new | ||
| run: cd new && cargo build-dev --release | ||
|
|
||
| - name: Run `compile-timer` on old | ||
| run: | | ||
| export PATH="${{ github.workspace }}/old/scripts:$PATH" | ||
| cd old/tests/perf/s2n-quic && ../../../target/release/compile-timer --out-path compile-times-old.json --also-visit quic/s2n-quic-core --also-visit quic/s2n-quic-platform --also-visit common/s2n-codec --skip-current | ||
| - name: Run `compile-timer` on new | ||
| run: | | ||
| export PATH="${{ github.workspace }}/new/scripts:$PATH" | ||
| cd new/tests/perf/s2n-quic && ../../../target/release/compile-timer --out-path compile-times-new.json --also-visit quic/s2n-quic-core --also-visit quic/s2n-quic-platform --also-visit common/s2n-codec --skip-current | ||
| - name: Run analysis between the two | ||
| run: ./new/target/release/compile-analyzer --path-pre old/tests/perf/s2n-quic/compile-times-old.json --path-post new/tests/perf/s2n-quic/compile-times-new.json --only-markdown --suite-name long >> "$GITHUB_STEP_SUMMARY" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| # Copyright Kani Contributors | ||
| # SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
|
||
| [package] | ||
| name = "compile-timer" | ||
| version = "0.1.0" | ||
| edition = "2024" | ||
| license = "MIT OR Apache-2.0" | ||
|
|
||
| [dependencies] | ||
| clap = { version = "4.5.40", features = ["derive"] } | ||
| serde = {version = "1.0.219", features = ["derive"]} | ||
| serde_json = "1.0.140" | ||
|
|
||
| [[bin]] | ||
| name = "compile-timer" | ||
| path = "src/compile-timer.rs" | ||
|
|
||
| [[bin]] | ||
| name = "compile-analyzer" | ||
| path = "src/compile-analyzer.rs" | ||
|
|
||
| [lints] | ||
| workspace = true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| # Compile-Timer | ||
| This is a simple script for timing the Kani compiler's end-to-end performance on crates. | ||
|
|
||
| ## Setup | ||
| You can run it by first compiling Kani (with `cargo build-dev --release` in the project root), then building this script (with `cargo build --release` in this `compile-timer` directory). This will build new `compile-timer` & `compile-analyzer` binaries in `kani/target/release`. | ||
|
|
||
| ## Recording Compiler Times with `compile-timer` | ||
| After doing that, you should make sure you have Kani on your $PATH (see instructions [here](https://model-checking.github.io/kani/build-from-source.html#adding-kani-to-your-path)) after which you can run `compile-timer --out-path [OUT_JSON_FILE]` in any directory to profile the compiler's performance on it. | ||
|
|
||
| By default, the script recursively goes into directories and will use `cargo kani` to profile any Rust projects it encounters (which it determines by looking for a `Cargo.toml`). You can tell it to ignore specific subtrees by passing in the `--ignore [DIR_NAME]` flag. | ||
|
|
||
| ## Visualizing Compiler Times with `compile-analyzer` | ||
| `compile-timer` itself will have some debug output including each individual run's time and aggregates for each crate. | ||
|
|
||
| `compile-analyzer` is specifically for comparing performance across multiple commits. | ||
|
|
||
| Once you've run `compile-timer` on both commits, you can run `compile-analyzer --path-pre [FIRST_JSON_FILE] --path-post [SECOND_JSON_FILE]` to see the change in performance going from the first to second commit. | ||
|
|
||
| By default, `compile-analyzer` will just print to the console, but if you specify the `--only-markdown` option, it's output will be formatted for GitHub flavored markdown (as is useful in CI). |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.