Repository navigation
Conversation
createBatchScheduler copied the whole queue on every schedule and passed a copy of the queued args to shouldSplitBatch, which call and multicall summed on every check. The queue now grows in place and shouldSplitBatch receives a running size built from getSize. Amp-Thread-ID: https://ampcode.com/threads/T-01a1e1b3-b2f5-71c9-92e4-458176671755 Co-authored-by: jxom <[email protected]>
Each data event copied the pending buffer twice and rescanned it from the first byte. The scanner state and the pending message's chunks now carry over between data events, and each message is concatenated once. Amp-Thread-ID: https://ampcode.com/threads/T-01a1e1b3-b2f5-71c9-92e4-458176671755 Co-authored-by: jxom <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: a48339e The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
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. |
|
Published pnpm add viem@pr-5526
pnpm add [email protected] |
|
Bundled into #5543 as its own commit, so this PR is superseded. Closing in favour of the bundle. |
Summary
Three hot paths copied or rescanned a growing buffer on every step, so their cost grew with the square of the input:
multicallchunking built each chunk withchunk = [...chunk, call]. It now pushes.createBatchSchedulercopied the queue on everyschedule([...queue, item]) and passed a fresh copy of the queued args toshouldSplitBatch, whichcallandmulticallthen summed on every check. The queue now grows in place, andshouldSplitBatchreceives a running size. A newgetSizeoption says how much each item adds (default 1, sohttpkeeps counting requests);callandmulticallpass their calldata length.createBatchScheduleris internal, so this changes no public API.dataevent (Uint8Array.fromandBuffer.concat) and rescanned it from byte 0.extractMessagesis replaced bycreateMessageExtractor, which keeps the scanner state (brace level, in-string, escaped) and the pending message's chunks acrossdataevents, and concatenates each message once. The string, escape and brace handling is unchanged; the existingipc.framing.test.tsandipc.test.tscases now run against the incremental extractor, including every split point and byte-by-byte delivery.The IPC change only touches the framing code. #5523 changes the
onClosewiring in the samegetSocket, so whichever lands second needs a small rebase around theonDatalines.Benchmarks
The benches are new colocated files, run on
mainand on this branch with the same file:SKIP_GLOBAL_SETUP=true ./node_modules/.bin/vitest bench -c ./test/vitest.config.ts --project core --run <file>(Node 26, mean per iteration,main→ this branch).src/utils/promise/createBatchScheduler.bench.ts: schedulenitems in one tick, onecreateBatchSchedulerper item sharing anid(ascallandhttpdo). The ~1.2ms floor is thesetTimeout(0)that flushes the batch.mainsrc/actions/public/multicall.bench.ts: realmulticalland batchedcallover HTTP against an ephemeral local JSON-RPC server that returns cannedaggregate3results.mainmulticall, 1,000 calls,batchSize: 1024multicall, 1,000 calls,batchSize: 0multicall, 10,000 calls,batchSize: 0calls into one multicallcalls into one multicallEnd to end, encoding and decoding dominate
multicallat 1,000 calls; the chunk copy shows from about 10,000 calls in one chunk. In isolation, chunking 1,000 calls withbatchSize: 0went from 731 to 46,211 ops/s in the audit's scratch bench.src/utils/rpc/ipc.bench.ts: one request over a real Unix socket whose response is delivered in 64KB chunks.mainThe audit's scratch script measured 4.1GB copied to frame the 16MB response on
main.Checks
pnpm test --run --project core src/actions/public/multicall.test.ts src/actions/public/call.test.ts src/clients/transports/http.test.ts src/clients/transports/ipc.test.ts src/utils/rpc/ src/utils/promise/createBatchScheduler.test.ts: all pass exceptcall.test.ts > errors > gas fee is less than block base fee, which fails the same way onmainin this environment (fork base fee).pnpm test --run --project core src/clients src/utils/promise src/actions/public/readContract.test.ts: 347 passed;public.test.ts > smoke test > getProoffailed with an upstream fork RPC error.pnpm check:types: clean