perf(bcs): closure-based encoder/decoder with bulk ops and bounds checks#1004
Draft
hayes-mysten wants to merge 3 commits intomainfrom
Draft
perf(bcs): closure-based encoder/decoder with bulk ops and bounds checks#1004hayes-mysten wants to merge 3 commits intomainfrom
hayes-mysten wants to merge 3 commits intomainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
f7cbdb0 to
fc2d4c3
Compare
fc2d4c3 to
d3a3e91
Compare
d3a3e91 to
833209c
Compare
a39ae28 to
1629d1c
Compare
fdf2673 to
1f07625
Compare
1f07625 to
ae249a2
Compare
ae249a2 to
84c5993
Compare
84c5993 to
aaca4d2
Compare
aaca4d2 to
d169584
Compare
d169584 to
c8fbcef
Compare
c8fbcef to
25458b2
Compare
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
25458b2 to
c3c82f2
Compare
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.
Description
Major performance rewrite of
@mysten/bcsreplacing the DataView-based reader/writer with a closure-based encoder/decoder architecture.Many performance ideas in this rewrite were inspired by @unconfirmedlabs/bcs by BL. Their work on codegen-based BCS decoding and object factory patterns informed several of the optimizations here.
Benchmarks vs main (Node.js, 100K iterations)
Serialize:
Deserialize:
Real-world TX Effects (1000 transactions, bun):
Architecture changes
bcs-decode.ts/bcs-encode.tswithcreateDecoder()/createEncoder()factories closing over private offset/buffer stateBcsType.parse()/toBytes(); independent instances for standaloneBcsReader/BcsWriterBcsReader/BcsWriterare now thin wrappers around decoder/encoder instancesuleb.ts— ULEB logic inlined into encoder/decoder closuresPerformance optimizations
Safety
parse()andread()— throwsRangeErroron truncated/malformed inputmaxSizeenforced inensure()during buffer growth (fails early)_codec.writeincludes validation)slice, notsubarray)$kind)Public API
index.tsBcsType:toBytes,toHex,toBase64,toBase58BcsType.read()andwrite()deprecated in favor ofparse()/toBytes()/serialize()BcsType.toBytes()is the fast path;serialize()wraps it withSerializedBcsTest plan
AI Assistance Notice