Repository navigation
HF-150: alternate base and head runs in the performance workflow #1805
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
base: develop
Are you sure you want to change the base?
Changes from all commits
cf2397f
f3158cb
a35630c
09a4cb0
c83f156
80535b6
673b83e
a83b017
4c4cee1
eb690a6
b3f2f68
18e62b2
feda6f1
12abee2
f58df37
6133856
0a3aa26
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| name: Performance (instruction count) | ||
| permissions: | ||
| contents: read | ||
|
|
||
| # Advisory companion of performance.yml. Instead of wall-clock time it counts the CPU instructions of each scenario's | ||
| # measured region with valgrind/callgrind, which does not depend on the load of the shared runner. The report goes to | ||
| # the job summary; nothing is posted to the pull request and the job never fails the pull request. | ||
| on: | ||
| pull_request: | ||
| types: | ||
| - opened | ||
| - reopened | ||
| - synchronize | ||
|
|
||
| jobs: | ||
| instruction-count: | ||
| name: Count instructions | ||
| runs-on: ubuntu-latest | ||
| continue-on-error: true | ||
| timeout-minutes: 60 | ||
| steps: | ||
| # Counts depend on the exact Node.js build; base and head run in this job on the same one. | ||
| - name: Setup Node.js | ||
| uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 | ||
| with: | ||
| node-version: '22' | ||
|
|
||
| - name: Install valgrind | ||
| run: | | ||
| sudo apt-get update | ||
| sudo apt-get install -y --no-install-recommends valgrind | ||
| valgrind --version | ||
|
|
||
| - name: (base) Checkout main repository | ||
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | ||
| with: | ||
| ref: ${{ github.event.pull_request.base.sha }} | ||
| path: base | ||
|
|
||
| - name: (head) Checkout main repository | ||
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | ||
| with: | ||
| path: head | ||
|
|
||
| - name: Checkout hyperformula-tests repository | ||
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | ||
| with: | ||
| ssh-key: ${{ secrets.DEPLOY_TOKEN }} | ||
| repository: handsontable/hyperformula-tests | ||
| path: head/hyperformula/test/hyperformula-tests | ||
|
|
||
| - name: Fetch hyperformula-tests and sync branches | ||
| run: cd head/hyperformula/test && ./fetch-tests.sh | ||
|
|
||
| # Both sides run the same (head) copy of the suite; only the engine under test differs. | ||
| - name: Share the tests between base and head | ||
| run: cp -r head/hyperformula/test/hyperformula-tests base/hyperformula/test/hyperformula-tests | ||
|
|
||
| - name: Record the revisions under test | ||
| run: | | ||
| echo "base: $(git -C base rev-parse HEAD)" | ||
| echo "head: $(git -C head rev-parse HEAD)" | ||
| echo "tests: $(git -C head/hyperformula/test/hyperformula-tests rev-parse HEAD)" | ||
| node --version | ||
|
|
||
| - name: (base) Install dependencies | ||
| run: cd base && npm ci | ||
|
|
||
| - name: (head) Install dependencies | ||
| run: cd head && npm ci | ||
|
|
||
| # A tests branch that predates the runner skips the counts with a notice instead of failing. | ||
| - name: Check for the instruction-count runner | ||
| id: runner | ||
| run: | | ||
| if [ -f head/hyperformula/test/hyperformula-tests/performance/run-instructions.ts ]; then | ||
| echo "present=true" >> "$GITHUB_OUTPUT" | ||
| else | ||
| echo "::notice::The paired hyperformula-tests branch predates the instruction-count runner; skipping." | ||
| fi | ||
|
|
||
| # The runner comes with the shared tests and is started through the generic tsnode script of the engine's | ||
| # package.json, which every revision has. Each run compiles the engine of its own tree into the same build directory and measures it | ||
| # there, so the two runs must stay sequential: the count depends on the paths a process sees. | ||
| - name: (base) Count instructions | ||
| if: steps.runner.outputs.present == 'true' | ||
| run: cd base && npm run tsnode --workspace=hyperformula test/hyperformula-tests/performance/run-instructions.ts "$GITHUB_WORKSPACE/base-instructions.json" | ||
|
|
||
| - name: (head) Count instructions | ||
| if: steps.runner.outputs.present == 'true' | ||
| run: cd head && npm run tsnode --workspace=hyperformula test/hyperformula-tests/performance/run-instructions.ts "$GITHUB_WORKSPACE/head-instructions.json" | ||
|
|
||
| - name: Compare the counts | ||
| if: steps.runner.outputs.present == 'true' | ||
| run: | | ||
| cd head && npm run tsnode --workspace=hyperformula test/hyperformula-tests/performance/compare-instructions.ts "$GITHUB_WORKSPACE/base-instructions.json" "$GITHUB_WORKSPACE/head-instructions.json" "$GITHUB_WORKSPACE/instructions-report.md" | ||
| cat "$GITHUB_WORKSPACE/instructions-report.md" >> "$GITHUB_STEP_SUMMARY" | ||
|
|
||
| - name: Print the raw counts | ||
| if: always() | ||
| run: | | ||
| for f in base-instructions head-instructions; do | ||
| echo "::group::$f.json" | ||
| cat "$GITHUB_WORKSPACE/$f.json" 2>/dev/null || echo "(missing)" | ||
| echo | ||
| echo "::endgroup::" | ||
| done |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,11 @@ on: | |
| - reopened | ||
| - synchronize # the head branch is updated from the base branch, new commits are pushed to the head branch, or the base branch is changed | ||
|
|
||
| # A newer push cancels the run of the same pull request, so an older run that finishes last cannot replace the newer table. | ||
| concurrency: | ||
| group: performance-${{ github.event.pull_request.number }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| performance-test: | ||
| strategy: | ||
|
|
@@ -18,59 +23,110 @@ jobs: | |
| os: [ 'ubuntu-latest' ] | ||
| name: Test performance | ||
| runs-on: ${{ matrix.os }} | ||
| timeout-minutes: 45 | ||
| steps: | ||
| - name: Setup Node.js ${{ matrix.node-version }} | ||
| uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 | ||
| with: | ||
| node-version: ${{ matrix.node-version }} | ||
|
|
||
| # Base and head live side by side so their runs can alternate. Measuring one side | ||
| # in a single block and the other afterwards lets the drift of a shared runner show up as a "regression"; | ||
| # alternating spreads that drift over both sides. | ||
| - name: (base) Checkout main repository | ||
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | ||
| with: | ||
| ref: ${{ github.event.pull_request.base.sha }} | ||
| path: base | ||
|
|
||
| - name: (head) Checkout main repository | ||
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | ||
| with: | ||
| path: head | ||
|
|
||
| - name: Checkout hyperformula-tests repository | ||
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | ||
| with: | ||
| ssh-key: ${{ secrets.DEPLOY_TOKEN }} | ||
| repository: handsontable/hyperformula-tests | ||
| path: hyperformula/test/hyperformula-tests | ||
| path: head/hyperformula/test/hyperformula-tests | ||
|
|
||
| - name: Fetch hyperformula-tests and sync branches | ||
| run: cd hyperformula/test && ./fetch-tests.sh | ||
| run: cd head/hyperformula/test && ./fetch-tests.sh | ||
|
|
||
| - name: (base) Install dependencies | ||
| run: npm ci | ||
| # Both sides run the same (head) copy of the suite; only the engine under test differs. | ||
| - name: Share the tests between base and head | ||
| run: cp -r head/hyperformula/test/hyperformula-tests base/hyperformula/test/hyperformula-tests | ||
|
|
||
| - name: (base) Run performance tests | ||
| run: npm run benchmark:write-to-file --workspace=hyperformula base.json | ||
| - name: Record the revisions under test | ||
| id: revisions | ||
| run: | | ||
| echo "base: $(git -C base rev-parse HEAD)" | ||
| echo "head: $(git -C head rev-parse HEAD)" | ||
| echo "tests: $(git -C head/hyperformula/test/hyperformula-tests rev-parse HEAD)" | ||
| echo "tests=$(git -C head/hyperformula/test/hyperformula-tests rev-parse --short HEAD)" >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: (head) Checkout main repository | ||
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | ||
| with: | ||
| clean: false | ||
| - name: (base) Install dependencies | ||
| run: cd base && npm ci | ||
|
|
||
| - name: (head) Install dependencies | ||
| run: npm ci | ||
| run: cd head && npm ci | ||
|
|
||
| - name: (head) Run performance tests | ||
| # Two rounds, each with half of the samples; the comparison merges the rounds of a side. The order is | ||
| # reversed in the second round (base, head, head, base) so that any effect of running first or second | ||
| # is shared by both sides. | ||
| - name: Run performance tests (alternating base and head) | ||
| env: | ||
| PERF_SAMPLE_SCALE: '0.5' | ||
| run: | | ||
| npm run benchmark:write-to-file --workspace=hyperformula head.json | ||
| run() { (cd "$1" && npm run benchmark:write-to-file --workspace=hyperformula "$GITHUB_WORKSPACE/$1-$2.json"); } | ||
| run base 1; run head 1 | ||
| run head 2; run base 2 | ||
|
Comment on lines
+75
to
+84
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With base, head, head, base, both head rounds run back to back in the middle of the job, so a runner slowdown that spans rounds 2–3 lands only on the head. The round-spread check can't see it: it compares the rounds within one side, and both head rounds are slow by the same amount. On identical code, with the committed noise history: // a 13% slowdown during rounds 2–3 (head-1, head-2)
compareSuites(mergeRounds([base1, base2]), mergeRounds([head1, head2]), undefined, history)
// 'Column ranges - add column' → regression, no notice
// the same slowdown during rounds 3–4 (head-2, base-2) → okThe eight-round order
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added to "What this suite cannot tell you" in handsontable/hyperformula-tests@140876d2eb45cb2be7d25e4356b0ba428aa41180. |
||
|
|
||
| # Exits non-zero when a results file is unreadable or nothing is comparable, so a broken comparison is a | ||
| # red check instead of a stale report. A regression is reported in the comment but does not fail this step. | ||
| # When the tests carry a noise history, each scenario is judged against the band of changes measured | ||
| # earlier on identical code. | ||
| - name: Compare the results | ||
| run: | | ||
| npm run benchmark:compare-benchmarks --workspace=hyperformula base.json head.json performance-report.md | ||
| HISTORY="$GITHUB_WORKSPACE/head/hyperformula/test/hyperformula-tests/performance/noise-history.json" | ||
| if [ -f "$HISTORY" ]; then export PERF_HISTORY_FILE="$HISTORY"; fi | ||
| cd head && npm run benchmark:compare-benchmarks --workspace=hyperformula "$GITHUB_WORKSPACE/base-1.json,$GITHUB_WORKSPACE/base-2.json" "$GITHUB_WORKSPACE/head-1.json,$GITHUB_WORKSPACE/head-2.json" "$GITHUB_WORKSPACE/performance-report.md" | ||
|
Comment on lines
+78
to
+94
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Which merges first, this PR or handsontable/hyperformula-tests#78? A Could you state the merge order in the description, and say how paired tests branches older than #78 are handled? Either they merge tests develop in, or the compare step ends with
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| # A tests branch older than the two-round comparison reads the comma-separated list as one file name, | ||
| # logs the error, exits 0 and writes no report. Fail here instead, so the failure comment below says so. | ||
| test -s "$GITHUB_WORKSPACE/performance-report.md" || { echo "No performance report: merge develop of hyperformula-tests into the paired tests branch." >&2; exit 1; } | ||
|
|
||
| # The runner is gone after the job; the raw samples in the log are what a later analysis can use. | ||
| - name: Print the raw samples | ||
| if: always() | ||
| run: | | ||
| for f in base-1 head-1 head-2 base-2; do | ||
| echo "::group::$f.json" | ||
| cat "$GITHUB_WORKSPACE/$f.json" 2>/dev/null || echo "(missing)" | ||
| echo | ||
| echo "::endgroup::" | ||
| done | ||
|
|
||
| - name: Publish a comment - header | ||
| uses: marocchino/sticky-pull-request-comment@5770ad5eb8f42dd2c4f34da00c94c5381e49af88 # v3.0.5 | ||
| with: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| message: | | ||
| ## Performance comparison of head (${{ github.event.pull_request.head.sha }}) vs base (${{ github.event.pull_request.base.sha }}) | ||
| ## Performance comparison of head (${{ github.event.pull_request.head.sha }}) vs base (${{ github.event.pull_request.base.sha }}) with the tests at ${{ steps.revisions.outputs.tests }} | ||
|
|
||
|
Comment on lines
+86
to
116
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When a benchmark round or the comparison fails, both sticky-comment steps are skipped, so the previous push's table and verdicts stay on the PR. That is the stale report the comment above this step says it avoids, and only the SHA in the header gives it away. Could you add a step like this after the publish steps, or reword the comment so it doesn't promise that? - name: Publish a comment - failure
if: failure()
uses: marocchino/sticky-pull-request-comment@6804b5ad49d19c10c9ae7cf5057352f7ff333f31 # https://github.com/marocchino/sticky-pull-request-comment/tree/v1.6.0
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
message: |
## Performance comparison of head (${{ github.event.pull_request.head.sha }}) failed; see the job log.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added a failure step in 4c4cee1: a failed run replaces the comment with one line that points to the job log. |
||
| - name: Publish a comment - performance comparison report | ||
| uses: marocchino/sticky-pull-request-comment@5770ad5eb8f42dd2c4f34da00c94c5381e49af88 # v3.0.5 | ||
| with: | ||
| append: true | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| path: hyperformula/performance-report.md | ||
| path: performance-report.md | ||
|
|
||
| # Replaces the previous push's table, so a failed, timed-out or cancelled run never leaves an older report | ||
| # standing for this head (a timeout counts as cancelled, not as a failure). | ||
| - name: Publish a comment - failure | ||
| if: failure() || cancelled() | ||
| uses: marocchino/sticky-pull-request-comment@5770ad5eb8f42dd2c4f34da00c94c5381e49af88 # v3.0.5 | ||
| with: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| message: | | ||
| ## Performance comparison of head (${{ github.event.pull_request.head.sha }}) did not finish; see the job log. | ||
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.
suggestion: Two runs for the same PR can overlap now: the job runs up to 45 minutes and nothing cancels the earlier run. If the earlier one finishes last, its table replaces the newer one, or its appended table lands under the newer header. A concurrency group would stop that:
The cancelled run then posts its "did not finish" line, and the newer run replaces it.