Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Comment thread
Tobiadefami marked this conversation as resolved.
Resolved

- 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"
Comment thread
Tobiadefami marked this conversation as resolved.
Resolved

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

Expand Down
Loading