Repository navigation
perf(0.x): hot-path speed and memory improvements, and Blobs.to multi-blob fix - #687
Merged
Merged
Conversation
- Hex.fromBytes uses native Uint8Array.prototype.toHex when available. - Bytes.fromHex decodes through a nibble table without copying the input. - Hex concat/slice/pad/trim strip the prefix without a search; Bytes pad/trim avoid per-byte loops and string conversions. - Hex.fromNumber fast path for unsigned safe integers. - Bytes.toBigInt builds small unsigned values as numbers. - Hex/Bytes/Address validate return false without throwing. - ABI decode: cursor tracks repeated reads in a bit set, decodeNumber shortcuts uint256, decodeAddress encodes a subarray, and getArrayComponents skips its regex for non-array types. - Checksum cache hits do one lookup. Amp-Thread-ID: https://ampcode.com/threads/T-01a1e11f-5ff6-753c-a73f-89ceda0ed7a9 Co-authored-by: jxom <jake@tempo.xyz>
Blobs.to treated the last 0x80 byte of any blob as the terminator, so multi-blob payloads with a 0x80 byte in a non-final blob lost data. It now finds the terminator once in the final blob and copies with byte loops, which also removes the quadratic rescan. Blobs.from writes field elements directly instead of through a cursor. Amp-Thread-ID: https://ampcode.com/threads/T-01a1e11f-5ff6-753c-a73f-89ceda0ed7a9 Co-authored-by: jxom <jake@tempo.xyz>
Amp-Thread-ID: https://ampcode.com/threads/T-01a1e11f-5ff6-753c-a73f-89ceda0ed7a9 Co-authored-by: jxom <jake@tempo.xyz>
Amp-Thread-ID: https://ampcode.com/threads/T-01a1e11f-5ff6-753c-a73f-89ceda0ed7a9 Co-authored-by: jxom <jake@tempo.xyz>
Amp-Thread-ID: https://ampcode.com/threads/T-01a1e11f-5ff6-753c-a73f-89ceda0ed7a9 Co-authored-by: jxom <jake@tempo.xyz>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Contributor
|
Published pnpm add ox@pr-687
pnpm add ox@0.0.0-pr-687-b2f312d |
Amp-Thread-ID: https://ampcode.com/threads/T-01a1e11f-5ff6-753c-a73f-89ceda0ed7a9 Co-authored-by: jxom <jake@tempo.xyz>
…che and pool resolve
Merged
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.
Performance and memory pass on the v0 line, plus the wins ported from the matching
mainpass. Every change was measured before/after withpnpm bench(same bench files on both sides) and a heap harness (bytes allocated and retained per call). Results are byte-identical to before, except theBlobs.tofix below.Fix
Blobs.totruncated multi-blob payloads at a0x80byte in a non-final blob (ports fix: Blobs.to truncates a payload at a 0x80 byte in a non-final blob #438 frommain). On 0.x, 60/60 random multi-blob round trips were corrupted before and 60/60 are correct after. Blobs of length ≡ 1 (mod 32) used to throwCursor.PositionOutOfBoundsErrorby accident and now decode.Speed and memory
Blobs.to, 6 blobsBlobs.to, 100 KB of0x80Blobs.from, 6 blobsHex.fromBytes(nativetoHexwhen available)Bytes.fromHex(nibble table, no copies)Hex.concat/slice/padLeft/trimLeftBytes.padLeft/trimLeft/toBooleanBytes.toBigInt, small valueHex.fromNumber, numberHex/Bytes/Address.validate, invalid inputuint256[1000]/address[100]uint256[1000]644 → 312 KB allocatedTxEnvelopeEip1559serialize / deserialize / getSignPayloadBase58.fromBytes/toBytes, 256 BTypedData.getSignPayload/hashStructVirtualMasterPool.resolve(), 8 concurrent cold callsABI encode is neutral to slightly faster (1.0–1.17x). Bench noise between runs is about ±10%.
Notes
decodeAddress). PublicBytes.slice/trimandRlpkeep copy semantics so callers' buffers can't be aliased.TypedDatatype-hash cache is bounded (1,024 entries) and cleared byCaches.clear.Hex.fromBytesfallback path (no nativetoHex, e.g. Node 24 in CI) was tested by deletingtoHexand rerunning the core suite.Uint8Array.fromHex(slower for small inputs), parallel imports inresolveNode(no measurable gain),pbkdf2AsyncinKeystore.toKeyAsync(noble yields only to microtasks, so timers still block).Tests
Offline core + tempo-unit suites match
0.x(3,216/3,257; the 33 failures need Anvil with a mainnet fork, which this environment can't reach). New: twoBlobs.toregression tests (both fail on the old code) and an unaligned repeated-read cursor test. Differential checks againstorigin/0.xcover Hex/Bytes/Address helpers,Bytes.fromHexerrors, Base58,Bytes.toBigInt, cursor read accounting (3,000 sequences), and Blobs.