perf: Replace biome manifest parsing with a span-tracking scanner - #13255
Merged
anthonyshew merged 1 commit intoJul 6, 2026
Merged
Conversation
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
anthonyshew
force-pushed
the
shew/package-json-fast-parse
branch
from
July 5, 2026 03:03
4588d7f to
5407d4b
Compare
Manifest parsing sits on the critical path of every run: one parse per workspace package. The general-purpose biome CST parser spent ~27us per manifest building a full syntax tree with error recovery; a purpose-built single-pass scanner extracts exactly what PackageJson needs in ~1-2us. Diagnostics keep their fidelity: Spanned fields carry the value token's full source range, so miette snippets in downstream errors (packageManager mismatches, devEngines validation, recursive turbo invocations) render with highlighted snippets as before, and parse errors point at the offending token. The biome deserializer and its manifest types are deleted outright; biome and turborepo-unescape drop out of the crate's dependency tree entirely. The parser's behavior contract is pinned by self-contained tests asserting values, exact byte ranges, attached metadata, and accept/reject decisions directly. serde_json's 128-level nesting limit applies when materializing unstructured field values. Also adds workspace_discovery/manifest_parse/add_packages spans to break down the package graph build phase in --profile output. On a 1191-package monorepo: manifest parse wall 29ms -> 8.8ms, parser CPU 46-60ms -> 3ms, TTFT median 258.7ms -> 250.4ms. Dry-run JSON is byte-identical.
anthonyshew
force-pushed
the
shew/package-json-fast-parse
branch
from
July 5, 2026 03:16
5407d4b to
577c820
Compare
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Manifest parsing sits on the critical path of every run: one parse per workspace package. The general-purpose biome CST parser earns its ~27µs/manifest through error recovery machinery that does nothing useful on valid manifests — which is nearly every manifest in every repo. A purpose-built scanner produces the same values, the same spans, and equivalent errors in ~1-2µs.
What
crate::manifest_parser: a single-pass, fully validating JSON scanner that buildsPackageJsondirectly. It is the only parse path — no tiering, no fallback — and the biome deserializer plus its manifest types are deleted outright. biome and turborepo-unescape drop out of the crate's dependency tree entirely.Spannedfields carry the value token's full source range (quotes/braces included), so miette snippets in downstream diagnostics — packageManager mismatch, devEngines validation (including key-search sub-spans), recursive-turbo — keep their highlighted snippets. Parse errors point at the offending token. The preexisting span-assertion tests pass unchanged.nullis a type error in typed fields but a validdevEnginesdeclaration. Known change: serde_json's 128-level nesting limit applies when materializing unstructured field values.workspace_discovery/manifest_parse/add_packagesspans to break downparse_package_jsonsin--profileoutput (this breakdown located the cost).How to verify
cargo test -p turborepo-repository— 289 tests, including all preexisting package-manager span assertions, unchanged.--dry=jsonbyte-identical.Stacked on #13250. Compounds with #13251, which removes the sequential turbo.json stats dominating the same discovery phase.