Skip to content

[heft-config-file] Add precompiled JSON schema validator support - #6100

Open
David Michon (dmichon-msft) with Copilot wants to merge 19 commits into
mainfrom
copilot/schema-precompilation-support
Open

David Michon (dmichon-msft) with Copilot wants to merge 19 commits into
mainfrom
copilot/schema-precompilation-support

Conversation

Copilot AI commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Motivation and measured win

Core Heft startup validates configuration and plugin metadata with AJV. Precompiling built-in validators moves that work from each invocation into the build. A paired comparison of actual builds of this PR and its main base across all 182 runnable downstream Heft consumers in the repository found faster boot on every measured project. The median per-project cold-start saving was 32.5 ms (15.6%), with a range of 18.7–61.3 ms. This supersedes the earlier single-project synthetic estimate.

Changes

  • Generation: Add a built-in Heft task plugin that emits standalone CommonJS and ESM validators from *.schema.json files. Generated modules resolve AJV runtime helpers through the deep @rushstack/node-core-library/lib/JsonSchemaRuntime import, so consuming projects do not need to resolve AJV themselves.
  • Runtime: Add jsonSchemaValidator to heft-config-file. Core Heft config, manifest, and built-in plugin option validation use generated validators. Other schema-publishing projects are not yet migrated.
new ProjectConfigurationFile({
  projectRelativeFilePath: 'config/my-plugin.json',
  jsonSchemaValidator: require('./schemas/my-plugin.validator.cjs')
});

Downstream startup profiling

Revisions: main base f11aaa2 vs PR 724c10d, each separately installed and built from source in its own directory on the same Linux host (Node 24.22.1). For each project declaring @rushstack/heft as a dependency (excluding Heft itself), launch that revision's self-built apps/heft/lib-commonjs/start.js from the project's folder with run --only _profiling_nonexistent_. This deliberately initializes real project configuration and plugin schemas, then stops at the same expected missing-phase error, before any build tasks execute. Both revisions produced that expected result for every measured project. Run one cold-process warmup per revision/project, then five paired cold-process measurements, alternating revision order; report the median of those five runs for each project. Wall time includes process launch; CPU and peak RSS are child-process resource usage. No synthetic validator hook or historical-code approximation was used.

Metric Main base (median project) PR (median project) Median paired saving
Startup wall time 207.7 ms 175.6 ms 32.5 ms (15.6%)
Process CPU time 281.9 ms 231.4 ms 51.5 ms (18.2%)
Peak RSS 88.0 MiB 81.7 MiB 6.3 MiB (7.1%)

Project coverage and median paired wall-time savings by repository area:

Project area Projects Median saved Faster on PR
apps 13 34.0 ms 13
build-tests 61 32.3 ms 61
build-tests-samples 14 30.7 ms 14
build-tests-subspace 4 33.3 ms 4
eslint 7 29.9 ms 7
heft-plugins 17 36.9 ms 17
libraries 34 31.8 ms 34
repo-scripts 2 29.9 ms 2
rush-plugins 11 33.2 ms 11
vscode-extensions 5 34.1 ms 5
webpack 14 29.4 ms 14
Total 182 32.5 ms 182

Of the 188 repository projects declaring a Heft dependency besides Heft itself, six are rig packages, not standalone Heft build projects: @rushstack/heft-node-rig, @rushstack/heft-vscode-extension-rig, @rushstack/heft-web-rig, decoupled-local-node-rig, local-node-rig, and local-web-rig. They have no root config/heft.json; starting Heft from their package folders fails on both revisions, so they are excluded rather than counted as successful boots. Their consuming projects are included. These results measure initialization through command selection, not build-task execution or performance of external Heft consumers.

Copilot AI and others added 2 commits September 29, 2026 20:45
Co-authored-by: dmichon-msft <26827560+dmichon-msft@users.noreply.github.com>
Co-authored-by: dmichon-msft <26827560+dmichon-msft@users.noreply.github.com>
Copilot AI changed the title [heft-config-file] Add support for precompiled JSON schema validation [heft-config-file] Add precompiled JSON schema validator support Sep 29, 2026
Copilot AI and others added 2 commits September 30, 2026 21:20
Co-authored-by: dmichon-msft <26827560+dmichon-msft@users.noreply.github.com>
Co-authored-by: dmichon-msft <26827560+dmichon-msft@users.noreply.github.com>
Copilot AI and others added 10 commits September 30, 2026 21:48
Co-authored-by: dmichon-msft <26827560+dmichon-msft@users.noreply.github.com>
Co-authored-by: dmichon-msft <26827560+dmichon-msft@users.noreply.github.com>
Co-authored-by: dmichon-msft <26827560+dmichon-msft@users.noreply.github.com>
Co-authored-by: dmichon-msft <26827560+dmichon-msft@users.noreply.github.com>
Co-authored-by: dmichon-msft <26827560+dmichon-msft@users.noreply.github.com>
Co-authored-by: dmichon-msft <26827560+dmichon-msft@users.noreply.github.com>
Co-authored-by: dmichon-msft <26827560+dmichon-msft@users.noreply.github.com>
Co-authored-by: dmichon-msft <26827560+dmichon-msft@users.noreply.github.com>
Co-authored-by: dmichon-msft <26827560+dmichon-msft@users.noreply.github.com>
Co-authored-by: dmichon-msft <26827560+dmichon-msft@users.noreply.github.com>
Copilot AI and others added 2 commits September 30, 2026 23:19
Co-authored-by: dmichon-msft <26827560+dmichon-msft@users.noreply.github.com>
Co-authored-by: dmichon-msft <26827560+dmichon-msft@users.noreply.github.com>

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.

Copilot Fix the comment


it('publishes a precompiled validator for every JSON schema', () => {
const schemaFiles: string[] = fs
.readdirSync(schemaFolder)

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.

Always use withFileTypes: true for readdir calls

Co-authored-by: dmichon-msft <26827560+dmichon-msft@users.noreply.github.com>

Copilot AI commented Oct 26, 2026

Copy link
Copy Markdown
Contributor Author

Copilot Fix the comment

Fixed in 724c10d: the schema test now calls readdirSync with withFileTypes: true and filters file entries. The targeted test could not start because the configured package-feed hostname returned ENOTFOUND.

Copilot AI and others added 2 commits October 27, 2026 21:14
Co-authored-by: dmichon-msft <26827560+dmichon-msft@users.noreply.github.com>
Co-authored-by: dmichon-msft <26827560+dmichon-msft@users.noreply.github.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Needs triage

Development

Successfully merging this pull request may close these issues.

2 participants