Repository navigation
perf(downgrader): look up a kept $ref's target only for a null anyOf pair in 3.1 to 3.0 - #89
Merged
Merged
Conversation
…pair in 3.1 to 3.0 #88 resolved and checked the target of every kept schema `$ref`, though only a `$ref` beside the null branch of a two-branch `anyOf` reads the result. `mergeNullable` now looks up that target in the input itself, which is always complete, so the cycle concern goes away too. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012Ly7PKnnYtmt4xpZpzZuWp
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — the perf follow-up to #88 that defers the null-rejecting $ref check from conversion time to mergeNullable.
shared.ts— exportsfind, the uncached pointer lookupresolvePointerwraps, with a doc comment. No logic change.v3.1-to-v3.0.ts— removesNULL_REJECTING_REFSand its fill inconvertSchemaRef;mergeNullablenow takesrootand, for a kept$refbranch, checksrejectsNull(find(root, ref)).- Equivalence — old
resolvePointer(ref, ctx)resolved against the same immutable input root thatdowngradeV30now passes in, and$refbranches reaching the merge always originate fromconvertSchemaRef, so the WeakSet identity check and thegetRefcheck cover the same branches. The full downgrader suite (252 tests) passes, including the existing kept-$refand cyclic-schema cases.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
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.

Requested by dinwwwh · project thread
#88 made 3.1 to 3.0 about 6 to 7% slower on
$ref-heavy docs. Wall time on the bench doc went from 15.1 to 16.1 ms, and on Discord from 19.1 to 20.3 ms. CodSpeed's simulation mode doesn't catch it. The cause:convertSchemaRefresolved and checked the target of every kept schema$refand added it to aWeakSet. Only a$refbeside the null branch of a two-branchanyOfever reads that result.This PR moves the check into
mergeNullable, so it runs only for those pairs:shared.tsexportsfind, the uncached pointer lookup thatresolvePointeralready wraps.NULL_REJECTING_REFSand the check inconvertSchemaRefare removed.downgradeV30passesroottomergeNullable. When the other branch is a kept$ref,mergeNullablechecks the target in the input withrejectsNull(find(root, ref)). The input is always complete, so a cycle can't hand it a half-converted target.Output doesn't change. All 256 tests and both snapshots (oRPC and corpus) pass with no edits. A separate check found byte-identical output to #88 on 41 real docs and 5,403 fuzz cases, with speed back to the pre-#88 level (15.4 ms and 19.0 ms). Locally,
vitest benchputs this branch ahead of main on "generated api, 100 resources" in both runs.pnpm run checkpasses.Generated by Claude Code