Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
cf2397f
HF-150: alternate base and head runs in the performance workflow
marcin-kordas-hoc Oct 11, 2026
f3158cb
HF-150: drop the artifact upload from the performance workflow
marcin-kordas-hoc Oct 11, 2026
a35630c
HF-150: bound the performance job and log the revisions it measures
marcin-kordas-hoc Oct 12, 2026
09a4cb0
HF-150: print the raw samples of every round into the job log
marcin-kordas-hoc Oct 12, 2026
c83f156
HF-150: show the revision of the tests in the comparison header
marcin-kordas-hoc Oct 12, 2026
80535b6
HF-150: use the noise history of the tests when it is present
marcin-kordas-hoc Oct 13, 2026
673b83e
Merge branch 'develop' into feat/hf-150-perf-gate
marcin-kordas-hoc Oct 22, 2026
a83b017
HF-150: say how to read the performance comparison on a pull request
marcin-kordas-hoc Oct 22, 2026
4c4cee1
Fail the performance job without a report and replace the comment whe…
marcin-kordas-hoc Nov 4, 2026
eb690a6
Merge branch 'develop' into feat/hf-150-perf-gate
marcin-kordas-hoc Nov 4, 2026
b3f2f68
Merge branch 'develop' into feat/hf-150-perf-gate
marcin-kordas-hoc Nov 4, 2026
18e62b2
Replace the performance comment also when the job times out or is can…
marcin-kordas-hoc Nov 20, 2026
feda6f1
Merge remote-tracking branch 'origin/develop' into feat/hf-150-perf-gate
marcin-kordas-hoc Nov 23, 2026
12abee2
Merge branch 'develop' into feat/hf-150-perf-gate
marcin-kordas-hoc Nov 23, 2026
f58df37
HF-150: advisory instruction-count workflow (prototype) (#1814)
marcin-kordas-hoc Nov 25, 2026
6133856
Merge remote-tracking branch 'origin/develop' into wt-hf1805
marcin-kordas-hoc Dec 3, 2026
0a3aa26
HF-150: cancel an earlier performance run of the same pull request
marcin-kordas-hoc Dec 3, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 107 additions & 0 deletions .github/workflows/performance-instructions.yml
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
88 changes: 72 additions & 16 deletions .github/workflows/performance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -18,59 +23,110 @@ jobs:
os: [ 'ubuntu-latest' ]
name: Test performance
runs-on: ${{ matrix.os }}
timeout-minutes: 45

Copy link
Copy Markdown
Collaborator

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:

concurrency:
  group: performance-${{ github.event.pull_request.number }}
  cancel-in-progress: true

The cancelled run then posts its "did not finish" line, and the newer run replaces it.

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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The 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) → ok

The eight-round order base head head base head base base head (scale 0.25) also cancels quadratic drift, but it only halves this effect (+7.05% vs ±6.4%, still regression). Could you name this blind spot under "What this suite cannot tell you" in the tests README?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The 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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which merges first, this PR or handsontable/hyperformula-tests#78? A pull_request run takes the workflow from the merge commit, so once this lands, every engine PR runs it against whatever tests branch fetch-tests.sh picks. The compare-benchmarks.ts on tests develop reads base-1.json,base-2.json as a single file name. It logs Cannot read results from …, exits 0 and writes no performance-report.md. The header step then replaces the comment with only the header, and the report step fails on the missing file. Those tests also ignore PERF_SAMPLE_SCALE, so all four rounds run the full 100 repetitions.

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 test -s "$GITHUB_WORKSPACE/performance-report.md" so the failure is clear.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hyperformula-tests#78 first, or both together; the description says so now. The compare step also ends with test -s on the report in 4c4cee1, so a tests branch older than #78 fails the job instead of posting only the header.

# 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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The 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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The 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.
2 changes: 1 addition & 1 deletion hyperformula/dev-docs/PERFORMANCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ HyperFormula is a calculation engine, so the performance of production code is a
- **Memory counts.** No cache grows without eviction, and no reference is left behind after sheets, rows or columns are removed. The memory footprint of a new cache is known and acceptable.
- **Bound the input.** Set a limit or a budget against huge ranges and very long strings.
- **Mind the bundle.** No unnecessary imports, polyfills or data tables.
- Run `npm run test:performance` for changes that may affect the evaluation or CRUD hot paths, and check the result is within noise.
- Run `npm run test:performance` for changes that may affect the evaluation or CRUD hot paths, and check the result is within noise. On a pull request, the Performance workflow posts a comment with an advisory verdict for each scenario; `hyperformula/test/hyperformula-tests/performance/README.md` explains where each threshold comes from and how to read the verdicts. A second workflow, Performance (instruction count), counts the CPU instructions of the same scenarios with valgrind, which does not depend on the load of the runner, and writes the comparison to the job summary; it is a prototype and never fails the pull request.

Hot paths worth knowing about before touching them:

Expand Down
Loading