Skip to content

feat(perf): lint repeated sort setup and schedule regression contracts - #18822

Merged
nwparker merged 3 commits into
mainfrom
nwparker/perf-better
Sep 5, 2026
Merged

nwparker merged 3 commits into
mainfrom
nwparker/perf-better

Conversation

@nwparker

@nwparker nwparker commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​51 $\color{#cf222e}{\Huge{\mathbf{−}}}$​6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​45
Prod 7 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​236 $\color{#cf222e}{\Huge{\mathbf{−}}}$​1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​235

ELI5 / TL;DR

Catch repeat performance mistakes before they reach users: add a lint rule for expensive setup repeated while sorting, plus a daily check of 54 existing performance regression tests on Mac, Windows, and Linux. The source audit found six candidates; one produced the measured sorting fix in #18823. The cross-platform tests also exposed two leaked SQLite test handles, now fixed. All three platforms pass.

The lint rule blocks new occurrences through the existing changed-code gate. The broader scan reports candidates for investigation; the daily tests catch regressions in the specific behaviors they cover.


Orca already guards fresh store selectors and growing buffer concatenations, but repeated collation setup inside sort callbacks still recurs. Add an Oxlint rule for optioned localeCompare / Intl.Collator inside inline sort and toSorted callbacks. It warns in ordinary lint and fails the existing changed-line quality gate for new occurrences; there is no autofix.

Add audit:perf for an advisory JSON inventory using that rule plus existing store/buffer rules, and test:perf:contracts to select existing production-path count, schema, concurrency, cancellation and backing-memory contracts. A daily/manual Linux/macOS/Windows workflow runs the selection and retains both reports; tooling changes also trigger it. This makes existing coverage easy to run and attribute, rather than claiming new runtime coverage. Missing listed tests fail configuration loading. Existing daily Electron terminal-scale CI remains the UI-latency check.

Local run on macOS arm64 / Node 24.18.0: 10 files, 54 tests passed in 3.33s. Source audit: six collation candidates, zero findings from the included store/buffer rules. Remaining candidates require workload measurements; a clean scan is not proof the app is fast. Named comparator functions and custom methods are outside the rule's semantic analysis. See config/performance-audit.md for commands and limits.

Validation: pnpm tc; changed-code quality; detector positive/negative fixtures; all 54 contracts; missing-file negative control; workflow YAML parsing; formatting and diff checks. The new contract/audit workflow passed on Linux, macOS and Windows: https://github.com/stablyai/orca/actions/runs/33959677757. The formatter also removes an existing duplicate package-script entry without changing its effective value.

The first Windows matrix run caught two pre-existing SQLite fixture leaks: the expected SQLITE_BUSY branches constructed readers without registering them for cleanup, so temp-file deletion failed with EBUSY. Both readers now use the fixture's existing openDatabases cleanup. The 54 tests pass locally after the fix; the Windows rerun passed, confirming handle release on the platform that rejects unlinking open files.

The audit's measured automation-sort result is split into #18823. The other five collation candidates remain advisory rather than receiving unmeasured bulk edits.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ℹ️ One minor suggestion inline — the plugin, audit, contracts, and workflow all check out end-to-end.

Reviewed changes

  • Oxlint plugin + rule (sort-comparator-performance/no-repeated-collator) — flags optioned localeCompare and Intl.Collator construction inside inline sort/toSorted callbacks; registered as warn in .oxlintrc.json and the new audit config.
  • audit:perf + config/oxlint-performance-audit.json — advisory JSON inventory over src combining the new rule with the existing store-selector and buffer-concat rules.
  • test:perf:contracts + config/vitest.performance.config.ts — selects 10 existing production-path contracts; missing listed files fail config load.
  • .github/workflows/performance-contracts.yml — daily/manual/PR-path workflow on Linux/macOS/Windows running the contracts and audit, uploading both JSON reports.
  • Docs and a formatter-driven duplicate-script dedup in package.json (effective value unchanged; the shadowed --disable-warning variant was already the losing duplicate key).

I verified the changed-line gate actually picks up the new warn rule (its "code quality" scan runs with no --config, so it inherits .oxlintrc.json), that audit:perf produces exactly six genuine positives and exits 0, and that test:perf:contracts runs 10 files / 54 tests — including the workflow's exact --reporter=json --outputFile invocation. The contract tests import no electron/node-pty/better-sqlite3 (SQLite is the built-in node:sqlite), so the workflow's native-runtime: none install is sufficient.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

- 'config/vitest.performance.config.ts'
- 'config/oxlint-performance-audit.json'
- 'config/oxlint-plugins/*performance.mjs'
- 'config/scripts/*performance-plugin.test.mjs'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This trigger list covers the plugin, its tests, and the audit/vitest configs, but not package.json (where audit:perf and test:perf:contracts are defined) or .oxlintrc.json (where no-repeated-collator is registered for the changed-line gate). A PR that edits a script definition — e.g. widening audit:perf to scan more than src — or re-tunes the rule registration would not run this workflow to validate the change. Consider adding package.json (and possibly .oxlintrc.json) to paths.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ℹ️ No new issues in this commit — the SQLite fixture fix is correct and verified. The one prior minor suggestion (workflow pull_request.paths coverage) remains the only open item; this commit doesn't touch it.

Reviewed changes

  • SQLite fixture leak fix — the two "read-only opens under contention" tests now register their SyncDatabase readers in the shared openDatabases list instead of constructing anonymous readers inside expect(...)/try, so afterEach closes them and Windows temp-dir cleanup stops failing with EBUSY. Assertions are preserved (errcode 5, database is locked, the ≥350ms busy-timeout bound), and it mirrors the existing openDatabases.push(reader) pattern in the sibling "succeeds once the writer commits" test. Confirmed 13/13 tests pass.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@coderabbitai

coderabbitai Bot commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Team

Run ID: 6552abd2-c474-4cc9-99f4-c8ee83e1485c

📥 Commits

Reviewing files that changed from the base of the PR and between 38352c6 and 297746f.

📒 Files selected for processing (2)
  • .github/workflows/performance-contracts.yml
  • config/performance-audit.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • config/performance-audit.md

Included review availability: Your plan provides up to 10 included reviews per hour; 5 remain after this review.


📝 Walkthrough

Walkthrough

The pull request adds a repeated-collator oxlint rule and performance audit configuration. It adds Vitest performance contract selection and package scripts. A scheduled, manual, and pull-request workflow runs the contracts and audits across three operating systems and uploads JSON artifacts. SQLite contention tests now retain database instances for cleanup, and a benchmark command removes a Node warning flag.

Merge Risk: ⚪ Minimal · up to 29774

This adds advisory performance auditing, contract-test automation, and SQLite test cleanup without an identified current-head correctness, security, or availability risk.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description gives a detailed ELI5 summary, change rationale, implementation scope, testing results, platform coverage, and limitations. However, it does not follow the required template because it… Add all required template sections. Include a linked issue using Fixes #..., write N/A with a reason for Visual Proof if no UI or interaction changed, complete or mark the AI Disclosure section, address Review and Agent skill upstream b…
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 4 files. (2 skipped: 2 … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the primary changes: adding performance linting for repeated sort setup and scheduling regression contract checks.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description gives a detailed ELI5 summary, change rationale, implementation scope, testing results, platform coverage, and limitations. However, it does not follow the required template because it omits the Linked Issue, Visual Proof or explicit N/A, AI Disclosure, Review, Agent skill upstream boundary, Notes, and Checklist sections.

Resolution

Add all required template sections. Include a linked issue using Fixes #..., write N/A with a reason for Visual Proof if no UI or interaction changed, complete or mark the AI Disclosure section, address Review and Agent skill upstream boundary, add Notes, and complete the Checklist items.

Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 4 files. (2 skipped: 2 unsupported.)

  • Fix all pre-merge checks with AI

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Without these paths a contract rename lands green on PR CI and only
breaks the next nightly, where nobody owns the failure. Also run the
OS-independent source audit once instead of on all three runners.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ℹ️ No new issues in this commit — the trigger-path and artifact changes are correct.

Reviewed changes

  • Trigger-path coverage — added config/oxlint-plugins/quadratic-buffer-concat.mjs (the one audit plugin the existing *performance.mjs glob missed), broadened the plugin-test glob to config/scripts/*-plugin.test.mjs, and listed the seven production-path contract files so edits to the contracts themselves re-run the workflow.
  • Linux-only source audit — audit:perf now runs only on ubuntu-latest (a static, OS-independent scan) and uploads as its own artifact; the per-OS contracts artifact now carries only performance-contracts.json.
  • Docs — config/performance-audit.md updated to describe per-OS results plus the single Linux audit.

I checked the globs against the on-disk files: quadratic-buffer-concat.mjs is the only audit plugin not matched by *performance.mjs, and *-plugin.test.mjs legitimately matches all five plugin test files (a harmless superset of the three used by the audit). The matrix.os == 'ubuntu-latest' gating is applied consistently to the audit step and its upload, so non-Linux runs won't fail on the missing performance-audit.json. The one open prior suggestion (package.json in pull_request.paths) is unchanged by this commit and remains for the author to decide.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@nwparker
nwparker merged commit 1924c8f into main Sep 5, 2026
31 checks passed
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
stablyai#18822)

* feat(perf): audit comparator setup and schedule performance contracts

* test(sqlite): close readers after expected busy failures

* ci(perf): trigger contract workflow on the contract files themselves

Without these paths a contract rename lands green on PR CI and only
breaks the next nightly, where nobody owns the failure. Also run the
OS-independent source audit once instead of on all three runners.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant