-
Notifications
You must be signed in to change notification settings - Fork 11
Test timings and effect of enabling avx2 #538
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
Open
robknight
wants to merge
5
commits into
main
Choose a base branch
from
test-timings
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
2dabd42
Test timings and effect of enabling avx2
robknight 5b6d3fd
Enable new workflows
robknight cec30dd
Allocator tests
robknight ca50d65
Finalise preferred test config in CI
robknight e53ef3f
Add +pclmulqdq alongside +avx2 in CI rustflags
robknight 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| #!/usr/bin/env python3 | ||
| """Aggregate pod2/plonky2 timing lines into a per-scope summary. | ||
|
|
||
| Recognises two line shapes: | ||
|
|
||
| timed "MainPod::prove": 7.068943638s <- pod2's `timed!` macro | ||
| [.. DEBUG plonky2::util::timing] 0.5s to fft <- plonky2's TimingTree | ||
|
|
||
| Usage: | ||
| summarise-timings.py [log] per-scope totals (stdin if no arg) | ||
| summarise-timings.py base.log other.log compare two runs, scope by scope | ||
|
|
||
| Tests run in parallel unless --test-threads=1 is passed, in which case samples | ||
| interleave and cannot be attributed to a test. Totals across the run still tell | ||
| you where the time goes, which is the point. | ||
| """ | ||
| import re | ||
| import sys | ||
| from collections import defaultdict | ||
|
|
||
| POD2 = re.compile(r'timed "([^"]+)": ([0-9.]+)(ms|µs|us|ns|s)\b') | ||
| PLONKY2 = re.compile(r"(?:\| )*([0-9.]+)s to (.+?)\s*$") | ||
| UNIT = {"s": 1.0, "ms": 1e-3, "us": 1e-6, "µs": 1e-6, "ns": 1e-9} | ||
|
|
||
|
|
||
| def parse(lines): | ||
| totals = defaultdict(list) | ||
| for line in lines: | ||
| m = POD2.search(line) | ||
| if m: | ||
| totals[m.group(1)].append(float(m.group(2)) * UNIT[m.group(3)]) | ||
| continue | ||
| if "util::timing" in line or line.lstrip().startswith("| "): | ||
| m = PLONKY2.search(line) | ||
| if m: | ||
| totals[m.group(2)].append(float(m.group(1))) | ||
| return totals | ||
|
|
||
|
|
||
| def summarise(totals): | ||
| rows = sorted(totals.items(), key=lambda kv: -sum(kv[1])) | ||
| print(f"{'scope':<44}{'n':>5}{'total':>11}{'mean':>10}{'max':>10}") | ||
| print("-" * 80) | ||
| for name, xs in rows: | ||
| print( | ||
| f"{name[:43]:<44}{len(xs):>5}{sum(xs):>10.2f}s" | ||
| f"{sum(xs) / len(xs):>9.2f}s{max(xs):>9.2f}s" | ||
| ) | ||
|
|
||
|
|
||
| def compare(base, other, base_name, other_name): | ||
| # Compare totals per scope. A scope missing from one side is reported as | ||
| # such rather than as a delta, since that means the runs were not | ||
| # equivalent and any percentage would be meaningless. | ||
| names = sorted(set(base) | set(other), key=lambda n: -sum(base.get(n, [0]))) | ||
| print(f"{'scope':<44}{base_name:>11}{other_name:>11}{'delta':>10}") | ||
| print("-" * 76) | ||
| for name in names: | ||
| if name not in base or name not in other: | ||
| side = base_name if name in base else other_name | ||
| print(f"{name[:43]:<44}{'(only in ' + side + ')':>32}") | ||
| continue | ||
| a, b = sum(base[name]), sum(other[name]) | ||
| delta = f"{(b - a) / a * 100:+.1f}%" if a > 0 else "n/a" | ||
| print(f"{name[:43]:<44}{a:>10.2f}s{b:>10.2f}s{delta:>10}") | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| args = sys.argv[1:] | ||
| if len(args) == 2: | ||
| with open(args[0]) as f: | ||
| base = parse(f) | ||
| with open(args[1]) as f: | ||
| other = parse(f) | ||
| if not base or not other: | ||
| sys.exit("no timing lines found in one of the logs") | ||
| compare(base, other, "base", "avx2") | ||
| else: | ||
| src = open(args[0]) if args else sys.stdin | ||
| totals = parse(src) | ||
| if not totals: | ||
| sys.exit( | ||
| "no timing lines found " | ||
| "(did you pass --features time and --nocapture?)" | ||
| ) | ||
| summarise(totals) | ||
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,50 @@ | ||
| name: Test timings | ||
|
|
||
| # Manual only: this exists to answer "what is CI actually spending its time on", | ||
| # not to gate anything. It costs nothing until someone runs it. | ||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| filter: | ||
| description: "Test name filter (empty runs the whole suite)" | ||
| required: false | ||
| default: "" | ||
|
|
||
| jobs: | ||
| timings: | ||
| name: Test timings | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Set up Rust | ||
| uses: actions-rust-lang/setup-rust-toolchain@v1 | ||
| with: | ||
| # Read the tests.yml cache but never write to it: the feature set here | ||
| # differs, and this job should not disturb the entry PRs restore from. | ||
| cache-shared-key: tests-release | ||
| cache-save-if: false | ||
| - name: Run tests with timing | ||
| # `--nocapture` is load-bearing. The `timed!` macro and plonky2's | ||
| # TimingTree both print, and libtest swallows stdout without it, so the | ||
| # timings silently vanish. Tests still run in parallel, so samples | ||
| # interleave and cannot be attributed to an individual test; the totals | ||
| # are what this job is for. | ||
| # | ||
| # The filter goes through env rather than being interpolated into the | ||
| # script: a dispatch input pasted straight into `run:` would let anyone | ||
| # who can trigger the workflow run arbitrary commands. | ||
| env: | ||
| FILTER: ${{ inputs.filter || '' }} | ||
| run: | | ||
| set -o pipefail | ||
| cargo test --release --features time,db_rocksdb ${FILTER:+"$FILTER"} \ | ||
| -- --nocapture 2>&1 | tee timings.log | ||
| - name: Summarise | ||
| if: always() | ||
| run: .github/workflows/scripts/summarise-timings.py < timings.log | ||
| - name: Upload full log | ||
| if: always() | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: timings | ||
| path: timings.log |
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is supposed to be generic?