Repository navigation
improvement(workflow-code): speed up stableStringify with byte-identical output - #10745
Merged
Merged
Conversation
…cal output Sort Object.keys with compareStrings and read fields directly instead of Object.entries, preallocate the array item buffer, and quote printable-ASCII keys without calling JSON.stringify. A seeded differential test pins the output, and the errors it throws, to the previous implementation.
Collaborator
Author
|
Greptile is currently unavailable, so this PR is merging on green CI plus a cubic review of the HEAD commit, with no unresolved threads. |
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
There was a problem hiding this comment.
All reported issues were addressed across 2 files
Reply with feedback, questions, or to request a fix.
Turn on auto-fix | Re-trigger cubic
Collaborator
Author
|
@cubic-dev-ai review this PR |
Contributor
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
This branch was previously 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.
Summary
stableStringify(the hash primitive behindcatalogHash, catalog compaction memo keys, and workflow hashes) now sortsObject.keys(...)withcompareStringsand reads fields directly instead of sortingObject.entriestuples, and quotes printable-ASCII keys without aJSON.stringifycall"or\still goes throughJSON.stringifyhashis unchanged before and after (same digest under Node and Bun)Measurements
Medians over 7 processes (5 warm iterations each), registry block catalog (513 blocks), Apple Silicon laptop. Node runs a
bun build --target=nodebundle; Bun runs the source directly.stableStringify(core)buildBlockCatalogcoldbuildBlockCatalogwarmA module-level memo of quoted keys measured about the same (Node build-cold 509.8 ms, warm 130.6 ms). I dropped it in favour of the stateless fast path, so no cache is needed. String concatenation instead of
joinwas slower on Node.Type of Change
Testing
hash.test.ts: 20k generated values (escape and boundary keys, lone surrogates,__proto__, null-prototype objects, -0, NaN/±Infinity, holes,undefined, functions) must give the same bytes and the sameTypeErrors as a frozen copy of the previous implementationundefinedfields each fail the testhash.test.tsandcatalog/compact.test.tspass;biome checkandcheck:utilsare clean. The full suite runs in CI.Checklist
test-auditauthoring gate)