From cf2397f917035e0f97995472cd1a74135775bcc7 Mon Sep 17 00:00:00 2001 From: marcin-kordas-hoc Date: Sun, 11 Oct 2026 23:15:46 +0000 Subject: [PATCH 01/11] HF-150: alternate base and head runs in the performance workflow Base and head are checked out side by side and measured in two rounds with the order reversed in the second one, so drift of a shared runner is spread over both sides. The raw samples are kept as a workflow artifact. Co-Authored-By: Claude Sonnet 5.5 --- .github/workflows/performance.yml | 55 ++++++++++++++++++++++--------- 1 file changed, 40 insertions(+), 15 deletions(-) diff --git a/.github/workflows/performance.yml b/.github/workflows/performance.yml index 9ef3c8190c..d750ef51ca 100644 --- a/.github/workflows/performance.yml +++ b/.github/workflows/performance.yml @@ -24,42 +24,67 @@ jobs: with: node-version: ${{ matrix.node-version }} + # Base and head live side by side so their runs can alternate (base, head, base, head). 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@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # https://github.com/actions/checkout/releases/tag/v2.3.4 with: ref: ${{ github.event.pull_request.base.sha }} + path: base + + - name: (head) Checkout main repository + uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # https://github.com/actions/checkout/releases/tag/v2.3.4 + with: + path: head - name: Checkout hyperformula-tests repository uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd with: ssh-key: ${{ secrets.DEPLOY_TOKEN }} repository: handsontable/hyperformula-tests - path: test/hyperformula-tests + path: head/test/hyperformula-tests - name: Fetch hyperformula-tests and sync branches - run: cd test && ./fetch-tests.sh - - - name: (base) Install dependencies - run: npm ci + run: cd head/test && ./fetch-tests.sh - - name: (base) Run performance tests - run: npm run benchmark:write-to-file base.json + # 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/test/hyperformula-tests base/test/hyperformula-tests - - name: (head) Checkout main repository - uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # https://github.com/actions/checkout/releases/tag/v2.3.4 - 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): the first process on a fresh runner is slow + #, and with a fixed order that penalty would always land on the same side. + - name: Run performance tests (alternating base and head) + env: + PERF_SAMPLE_SCALE: '0.5' run: | - npm run benchmark:write-to-file head.json + run() { (cd "$1" && npm run benchmark:write-to-file "$GITHUB_WORKSPACE/$1-$2.json"); } + run base 1; run head 1 + run head 2; run base 2 + # 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. - name: Compare the results run: | - npm run benchmark:compare-benchmarks base.json head.json performance-report.md + cd head && npm run benchmark:compare-benchmarks "$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" + + - name: Keep the raw samples + if: always() + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # https://github.com/actions/upload-artifact/releases/tag/v4.6.2 + with: + name: performance-results + path: | + base-*.json + head-*.json + performance-report.md + if-no-files-found: ignore - name: Publish a comment - header uses: marocchino/sticky-pull-request-comment@6804b5ad49d19c10c9ae7cf5057352f7ff333f31 # https://github.com/marocchino/sticky-pull-request-comment/tree/v1.6.0 From f3158cbdacfdca6d21b7406a72043eff4a04dd4a Mon Sep 17 00:00:00 2001 From: marcin-kordas-hoc Date: Sun, 11 Oct 2026 23:19:34 +0000 Subject: [PATCH 02/11] HF-150: drop the artifact upload from the performance workflow Keeping the raw samples as an artifact adds a new action dependency that the licence check flagged; persisting results across runs is left for a follow-up. Co-Authored-By: Claude Sonnet 5.5 --- .github/workflows/performance.yml | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/.github/workflows/performance.yml b/.github/workflows/performance.yml index d750ef51ca..f8ab660a3d 100644 --- a/.github/workflows/performance.yml +++ b/.github/workflows/performance.yml @@ -75,17 +75,6 @@ jobs: run: | cd head && npm run benchmark:compare-benchmarks "$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" - - name: Keep the raw samples - if: always() - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # https://github.com/actions/upload-artifact/releases/tag/v4.6.2 - with: - name: performance-results - path: | - base-*.json - head-*.json - performance-report.md - if-no-files-found: ignore - - name: Publish a comment - header uses: marocchino/sticky-pull-request-comment@6804b5ad49d19c10c9ae7cf5057352f7ff333f31 # https://github.com/marocchino/sticky-pull-request-comment/tree/v1.6.0 with: From a35630c9bc566c47efbd4ca2eb9f5f8c58a18bf9 Mon Sep 17 00:00:00 2001 From: marcin-kordas-hoc Date: Mon, 12 Oct 2026 04:08:36 +0000 Subject: [PATCH 03/11] HF-150: bound the performance job and log the revisions it measures Co-Authored-By: Claude Sonnet 5.5 --- .github/workflows/performance.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/performance.yml b/.github/workflows/performance.yml index f8ab660a3d..b69170342f 100644 --- a/.github/workflows/performance.yml +++ b/.github/workflows/performance.yml @@ -18,6 +18,7 @@ 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@56899e050abffc08c2b3b61f3ec6a79a9dc3223d # https://github.com/actions/setup-node/releases/tag/v1.4.4 @@ -52,6 +53,12 @@ jobs: - name: Share the tests between base and head run: cp -r head/test/hyperformula-tests base/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/test/hyperformula-tests rev-parse HEAD)" + - name: (base) Install dependencies run: cd base && npm ci From 09a4cb0f62e3ff7274cbb10341b64c354cb8d5d1 Mon Sep 17 00:00:00 2001 From: marcin-kordas-hoc Date: Mon, 12 Oct 2026 04:22:40 +0000 Subject: [PATCH 04/11] HF-150: print the raw samples of every round into the job log Co-Authored-By: Claude Sonnet 5.5 --- .github/workflows/performance.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.github/workflows/performance.yml b/.github/workflows/performance.yml index b69170342f..d6c608b18d 100644 --- a/.github/workflows/performance.yml +++ b/.github/workflows/performance.yml @@ -82,6 +82,17 @@ jobs: run: | cd head && npm run benchmark:compare-benchmarks "$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" + # 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@6804b5ad49d19c10c9ae7cf5057352f7ff333f31 # https://github.com/marocchino/sticky-pull-request-comment/tree/v1.6.0 with: From c83f1566add3a29c9f419ff9d97827c9c52d7efc Mon Sep 17 00:00:00 2001 From: marcin-kordas-hoc Date: Mon, 12 Oct 2026 08:55:57 +0000 Subject: [PATCH 05/11] HF-150: show the revision of the tests in the comparison header Co-Authored-By: Claude Sonnet 5.5 --- .github/workflows/performance.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/performance.yml b/.github/workflows/performance.yml index d6c608b18d..21ea8cc93e 100644 --- a/.github/workflows/performance.yml +++ b/.github/workflows/performance.yml @@ -54,10 +54,12 @@ jobs: run: cp -r head/test/hyperformula-tests base/test/hyperformula-tests - 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/test/hyperformula-tests rev-parse HEAD)" + echo "tests=$(git -C head/test/hyperformula-tests rev-parse --short HEAD)" >> "$GITHUB_OUTPUT" - name: (base) Install dependencies run: cd base && npm ci @@ -66,8 +68,8 @@ jobs: run: cd head && npm ci # 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): the first process on a fresh runner is slow - #, and with a fixed order that penalty would always land on the same side. + # 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' @@ -98,7 +100,7 @@ jobs: 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 }} - name: Publish a comment - performance comparison report uses: marocchino/sticky-pull-request-comment@6804b5ad49d19c10c9ae7cf5057352f7ff333f31 # https://github.com/marocchino/sticky-pull-request-comment/tree/v1.6.0 From 80535b6b995c490ce544a52ddfcfd3620068b82a Mon Sep 17 00:00:00 2001 From: marcin-kordas-hoc Date: Tue, 13 Oct 2026 06:14:53 +0000 Subject: [PATCH 06/11] HF-150: use the noise history of the tests when it is present Co-Authored-By: Claude Opus 5.5 --- .github/workflows/performance.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/performance.yml b/.github/workflows/performance.yml index 21ea8cc93e..ed3c919380 100644 --- a/.github/workflows/performance.yml +++ b/.github/workflows/performance.yml @@ -80,8 +80,12 @@ jobs: # 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: | + HISTORY=test/hyperformula-tests/performance/noise-history.json + if [ -f "head/$HISTORY" ]; then export PERF_HISTORY_FILE="$HISTORY"; fi cd head && npm run benchmark:compare-benchmarks "$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" # The runner is gone after the job; the raw samples in the log are what a later analysis can use. From a83b017128203a89e89205ca00e12b7c0f1f4a42 Mon Sep 17 00:00:00 2001 From: marcin-kordas-hoc Date: Thu, 22 Oct 2026 05:24:31 +0000 Subject: [PATCH 07/11] HF-150: say how to read the performance comparison on a pull request --- hyperformula/dev-docs/PERFORMANCE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hyperformula/dev-docs/PERFORMANCE.md b/hyperformula/dev-docs/PERFORMANCE.md index 2405e45b88..8d2a6027b8 100644 --- a/hyperformula/dev-docs/PERFORMANCE.md +++ b/hyperformula/dev-docs/PERFORMANCE.md @@ -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 that gives each scenario a verdict against the noise measured on identical code. The verdicts are advisory; `hyperformula/test/hyperformula-tests/performance/README.md` explains how to read them. Hot paths worth knowing about before touching them: From 4c4cee1b0e3fd354c2b929b3e79098f561a6c6f4 Mon Sep 17 00:00:00 2001 From: marcin-kordas-hoc Date: Wed, 4 Nov 2026 02:50:08 +0000 Subject: [PATCH 08/11] Fail the performance job without a report and replace the comment when it fails A tests branch older than the two-round comparison exits 0 without writing performance-report.md; the compare step now fails on a missing report, and a failure comment replaces the previous push's table. The comment above the checkouts no longer gives the round order, and PERFORMANCE.md no longer says every scenario is judged against the noise measured on identical code. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/performance.yml | 14 +++++++++++++- hyperformula/dev-docs/PERFORMANCE.md | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/.github/workflows/performance.yml b/.github/workflows/performance.yml index d9d502f6de..a8b2fd06ed 100644 --- a/.github/workflows/performance.yml +++ b/.github/workflows/performance.yml @@ -25,7 +25,7 @@ jobs: with: node-version: ${{ matrix.node-version }} - # Base and head live side by side so their runs can alternate (base, head, base, head). Measuring one side + # 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 @@ -87,6 +87,9 @@ jobs: 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" + # 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 @@ -112,3 +115,12 @@ jobs: append: true GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} path: performance-report.md + + # Replaces the previous push's table, so a failed run never leaves an older report standing for this head. + - 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. diff --git a/hyperformula/dev-docs/PERFORMANCE.md b/hyperformula/dev-docs/PERFORMANCE.md index 8d2a6027b8..b68fa549a5 100644 --- a/hyperformula/dev-docs/PERFORMANCE.md +++ b/hyperformula/dev-docs/PERFORMANCE.md @@ -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. On a pull request, the Performance workflow posts a comment that gives each scenario a verdict against the noise measured on identical code. The verdicts are advisory; `hyperformula/test/hyperformula-tests/performance/README.md` explains how to read them. +- 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. Hot paths worth knowing about before touching them: From 18e62b2215a31f319d56388eeda5ebde1f4519f0 Mon Sep 17 00:00:00 2001 From: marcin-kordas-hoc Date: Fri, 20 Nov 2026 13:45:03 +0000 Subject: [PATCH 09/11] Replace the performance comment also when the job times out or is cancelled failure() is false for a job stopped by timeout-minutes or cancelled, so the previous push's table stayed on the pull request. The step now runs on failure() || cancelled(), and its message says the comparison did not finish. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/performance.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/performance.yml b/.github/workflows/performance.yml index 94c9ab33ab..f03b71598e 100644 --- a/.github/workflows/performance.yml +++ b/.github/workflows/performance.yml @@ -116,11 +116,12 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} path: performance-report.md - # Replaces the previous push's table, so a failed run never leaves an older report standing for this head. + # 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() + 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 }}) failed; see the job log. + ## Performance comparison of head (${{ github.event.pull_request.head.sha }}) did not finish; see the job log. From f58df37ff2db83ad5dfa2996ed5a6176503aec30 Mon Sep 17 00:00:00 2001 From: marcin-kordas-hoc Date: Wed, 25 Nov 2026 15:48:14 +0700 Subject: [PATCH 10/11] HF-150: advisory instruction-count workflow (prototype) (#1814) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ### Context The PR adds an advisory workflow that compares base and head by the CPU instructions each performance scenario executes, instead of by time. - **Why:** on shared runners, wall-clock noise lets the timing comparison (#1805) show only regressions of about 5% or more per scenario, and it still reports false regressions. Instruction counts do not depend on the load of the runner. - **What changed:** - `.github/workflows/performance-instructions.yml`: installs valgrind, counts the instructions of every scenario for base and head (one after the other, from the same build directory), writes the comparison to the job summary and prints the raw counts into the log. Paths follow the monorepo layout. - The job never fails the pull request (`continue-on-error`) and posts no comment. `performance.yml` is unchanged. - When the paired tests branch has no `performance/run-instructions.ts`, the job skips the counts and the comparison with a notice instead of failing with module-not-found. - `hyperformula/dev-docs/PERFORMANCE.md`: one sentence about this workflow. - **Result:** every PR gets a per-scenario instruction-count comparison that can see changes well under 1%. - **Role:** the intended direction for the performance check, done in-house with valgrind on standard runners and without a vendor service. The wall-clock comparison stays as a temporary advisory layer, because instruction counts do not see GC pauses, memory or cache effects. ### How did you test your changes? - Paired tests branch: `feat/hf-150-instruction-count` in `hyperformula-tests`. - This PR changes no engine code, so every scenario should come out at about 0%. CI runs: | Run | Largest change over 13 scenarios | Job time | |---|---:|---:| | before the monorepo merge | 0.0075% | 7m39s | | after the monorepo merge (63b4b92e5) | 0.00022% | 10m37s | | with the runner check and the scenario table (7ded1cc2a, tests dae23a2) | 0.0056% | 11m58s | | with the action pins of `performance.yml` and the zero-count check (ff3019a7e, tests f9f0e41) | 0.00147% | 6m52s | - A throwaway control PR that added a fixed loop to `setCellContents` moved every scenario that calls it by +0.06% to +3.97%, and every other scenario by at most 0.013%. - Locally, in the monorepo layout: one scenario counted end to end under valgrind. - The runner check, run as a script against three tests refs: `develop` and `feat/hf-150-perf-gate` (no runner) print the notice and set no output, so the three guarded steps skip; `feat/hf-150-instruction-count` sets `present=true`. ### AI assistance Claude Code co-authored 5 of the 7 non-merge commits on this branch (the workflow) and 7 of the 8 on the paired `hyperformula-tests` branch (the instruction-count runner), as the `Co-Authored-By: Claude` trailers record. The other 2 and 1 commits carry no such trailer. ### Compatibility with Excel and Google Sheets Not applicable. ### Public API changes None. ### Out of scope and follow-ups - A blocking check. - Scale scenarios: stacked PR #1838 (100k rows in the wall-clock suite, 30k in the instruction count). ### Types of changes - [ ] Breaking change (existing functionality no longer works as before) – agreed with the maintainers - [ ] New feature or improvement (a non-breaking change that adds functionality) - [ ] Bug fix (a non-breaking change that fixes an issue) - [ ] Additional language file, or a change to an existing language file (translations) - [x] Change to the documentation CI tooling only, plus one sentence in `dev-docs/`. ### Related issues 1. HF-150 (internal task) ### Checklist - [ ] My pull request meets the [Definition of Done](https://github.com/handsontable/hyperformula/blob/develop/dev-docs/DEFINITION-OF-DONE.md). External contributors: see also [Contributing to HyperFormula](https://handsontable.com/docs/hyperformula/guide/contributing.html). - [ ] I have signed the [Contributor License Agreement](https://goo.gl/forms/yuutGuN0RjsikVpM2). - [x] I read my own diff end to end before requesting a review. - [x] I added a [CHANGELOG.md](https://github.com/handsontable/hyperformula/blob/develop/CHANGELOG.md) entry, written by [the changelog rules](https://github.com/handsontable/hyperformula/blob/develop/dev-docs/DOC-STANDARDS.md#the-changelog) – or none is needed (docs, tests or tooling only). - [x] I updated the documentation and JSDoc to match the change. - [ ] Breaking change only: I added a section to the migration guide. - [x] I updated the `dev-docs/` pages this change affects – or none needed it. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- > [!NOTE] > **Low Risk** > CI-only addition with read permissions and no PR gating; engine code and public APIs are unchanged. > > **Overview** > Adds a **prototype GitHub Actions workflow** (`Performance (instruction count)`) that runs on pull requests alongside the existing wall-clock **Performance** job, without changing that workflow. > > The new job checks out **base** and **head**, shares the paired **hyperformula-tests** suite (including valgrind-based runners when present), runs `run-instructions.ts` sequentially for each side, compares results with `compare-instructions.ts`, and appends the report to the **job summary**. It uses **`continue-on-error`**, does not comment on the PR, and skips counting with a notice if `performance/run-instructions.ts` is missing on the tests branch. > > **`hyperformula/dev-docs/PERFORMANCE.md`** gains one sentence describing this advisory instruction-count check. > > Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit ff3019a7eaa5cba6f3895bdf5b763d3e33df387b. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot). --------- Co-authored-by: Claude Opus 5.5 --- .../workflows/performance-instructions.yml | 107 ++++++++++++++++++ hyperformula/dev-docs/PERFORMANCE.md | 2 +- 2 files changed, 108 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/performance-instructions.yml diff --git a/.github/workflows/performance-instructions.yml b/.github/workflows/performance-instructions.yml new file mode 100644 index 0000000000..e3eee14467 --- /dev/null +++ b/.github/workflows/performance-instructions.yml @@ -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 diff --git a/hyperformula/dev-docs/PERFORMANCE.md b/hyperformula/dev-docs/PERFORMANCE.md index b68fa549a5..dc5e94dac7 100644 --- a/hyperformula/dev-docs/PERFORMANCE.md +++ b/hyperformula/dev-docs/PERFORMANCE.md @@ -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. 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. +- 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: From 0a3aa268af386805c8ec61b1643ba5449f94cafd Mon Sep 17 00:00:00 2001 From: marcin-kordas-hoc Date: Thu, 3 Dec 2026 07:54:02 +0000 Subject: [PATCH 11/11] HF-150: cancel an earlier performance run of the same pull request Co-Authored-By: Claude Sonnet 5.5 --- .github/workflows/performance.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/performance.yml b/.github/workflows/performance.yml index f03b71598e..377525c0a2 100644 --- a/.github/workflows/performance.yml +++ b/.github/workflows/performance.yml @@ -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: