perf(bcs): closure-based encoder/decoder with bulk ops and bounds checks#1004
Draft
hayes-mysten wants to merge 3 commits into
Draft
perf(bcs): closure-based encoder/decoder with bulk ops and bounds checks#1004hayes-mysten wants to merge 3 commits into
hayes-mysten wants to merge 3 commits into
Conversation
hayes-mysten
had a problem deploying
to
sui-typescript-aws-kms-test-env
April 7, 2026 00:18 — with
GitHub Actions
Failure
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
hayes-mysten
had a problem deploying
to
sui-typescript-aws-kms-test-env
April 7, 2026 00:27 — with
GitHub Actions
Failure
hayes-mysten
had a problem deploying
to
sui-typescript-aws-kms-test-env
April 7, 2026 00:30 — with
GitHub Actions
Failure
hayes-mysten
had a problem deploying
to
sui-typescript-aws-kms-test-env
April 7, 2026 00:35 — with
GitHub Actions
Failure
hayes-mysten
had a problem deploying
to
sui-typescript-aws-kms-test-env
April 7, 2026 00:36 — with
GitHub Actions
Failure
hayes-mysten
had a problem deploying
to
sui-typescript-aws-kms-test-env
April 7, 2026 00:38 — with
GitHub Actions
Failure
hayes-mysten
had a problem deploying
to
sui-typescript-aws-kms-test-env
April 7, 2026 00:45 — with
GitHub Actions
Failure
hayes-mysten
had a problem deploying
to
sui-typescript-aws-kms-test-env
April 7, 2026 00:47 — with
GitHub Actions
Failure
hayes-mysten
had a problem deploying
to
sui-typescript-aws-kms-test-env
April 7, 2026 00:58 — with
GitHub Actions
Failure
hayes-mysten
had a problem deploying
to
sui-typescript-aws-kms-test-env
April 7, 2026 00:59 — with
GitHub Actions
Failure
hayes-mysten
force-pushed
the
worktree-bcs-perf-optimizations
branch
from
April 7, 2026 01:10
f7cbdb0 to
fc2d4c3
Compare
hayes-mysten
had a problem deploying
to
sui-typescript-aws-kms-test-env
April 7, 2026 01:10 — with
GitHub Actions
Failure
hayes-mysten
force-pushed
the
worktree-bcs-perf-optimizations
branch
from
April 7, 2026 01:36
fc2d4c3 to
d3a3e91
Compare
hayes-mysten
temporarily deployed
to
sui-typescript-aws-kms-test-env
April 7, 2026 01:36 — with
GitHub Actions
Inactive
hayes-mysten
force-pushed
the
worktree-bcs-perf-optimizations
branch
from
April 7, 2026 02:05
d3a3e91 to
833209c
Compare
hayes-mysten
temporarily deployed
to
sui-typescript-aws-kms-test-env
April 7, 2026 02:05 — with
GitHub Actions
Inactive
hayes-mysten
temporarily deployed
to
sui-typescript-aws-kms-test-env
April 7, 2026 02:09 — with
GitHub Actions
Inactive
hayes-mysten
force-pushed
the
worktree-bcs-perf-optimizations
branch
from
April 7, 2026 06:39
a39ae28 to
1629d1c
Compare
hayes-mysten
temporarily deployed
to
sui-typescript-aws-kms-test-env
April 7, 2026 06:39 — with
GitHub Actions
Inactive
hayes-mysten
temporarily deployed
to
sui-typescript-aws-kms-test-env
April 7, 2026 16:53 — with
GitHub Actions
Inactive
hayes-mysten
force-pushed
the
worktree-bcs-perf-optimizations
branch
from
April 7, 2026 16:53
fdf2673 to
1f07625
Compare
hayes-mysten
temporarily deployed
to
sui-typescript-aws-kms-test-env
April 7, 2026 16:54 — with
GitHub Actions
Inactive
hayes-mysten
force-pushed
the
worktree-bcs-perf-optimizations
branch
from
April 7, 2026 17:03
1f07625 to
ae249a2
Compare
hayes-mysten
temporarily deployed
to
sui-typescript-aws-kms-test-env
April 7, 2026 17:04 — with
GitHub Actions
Inactive
hayes-mysten
force-pushed
the
worktree-bcs-perf-optimizations
branch
from
April 7, 2026 17:13
ae249a2 to
84c5993
Compare
hayes-mysten
temporarily deployed
to
sui-typescript-aws-kms-test-env
April 7, 2026 17:13 — with
GitHub Actions
Inactive
hayes-mysten
force-pushed
the
worktree-bcs-perf-optimizations
branch
from
April 7, 2026 17:31
84c5993 to
aaca4d2
Compare
hayes-mysten
temporarily deployed
to
sui-typescript-aws-kms-test-env
April 7, 2026 17:31 — with
GitHub Actions
Inactive
hayes-mysten
force-pushed
the
worktree-bcs-perf-optimizations
branch
from
April 7, 2026 17:34
aaca4d2 to
d169584
Compare
hayes-mysten
temporarily deployed
to
sui-typescript-aws-kms-test-env
April 7, 2026 17:34 — with
GitHub Actions
Inactive
hayes-mysten
force-pushed
the
worktree-bcs-perf-optimizations
branch
from
April 7, 2026 17:39
d169584 to
c8fbcef
Compare
hayes-mysten
temporarily deployed
to
sui-typescript-aws-kms-test-env
April 7, 2026 17:39 — with
GitHub Actions
Inactive
hayes-mysten
force-pushed
the
worktree-bcs-perf-optimizations
branch
from
April 7, 2026 17:46
c8fbcef to
25458b2
Compare
hayes-mysten
temporarily deployed
to
sui-typescript-aws-kms-test-env
April 7, 2026 17:47 — with
GitHub Actions
Inactive
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>
hayes-mysten
force-pushed
the
worktree-bcs-perf-optimizations
branch
from
April 7, 2026 17:56
25458b2 to
c3c82f2
Compare
hayes-mysten
temporarily deployed
to
sui-typescript-aws-kms-test-env
April 7, 2026 17:56 — with
GitHub Actions
Inactive
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