Skip to content

perf(encoding): encode execute and enqueue calldata with a cached ox AbiFunction - #60

Merged
kyscott18 merged 1 commit into
mainfrom
perf/ox-execute-calldata
Oct 13, 2026
Merged

kyscott18 merged 1 commit into
mainfrom
perf/ox-execute-calldata

Conversation

@kyscott18

@kyscott18 kyscott18 commented Oct 13, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

viem's encodeFunctionData looks up the ABI item and hashes the selector on every call. The runtime encodes execute calldata for each accepted mutation. This PR uses AbiFunction.encodeData from ox with the execute and enqueue functions resolved once at module load. This follows the "prefer ox" rule in AGENTS.md.

Results

  • Micro-benchmark, one-mutation execute calldata: 14.6 µs (viem) → 3.5 µs (ox, cached).
  • In the runtime, the encode step fell from 44–62 µs to 20–29 µs per mutation.
  • Counter benchmark, open loop at 8,000/s, with the other PRs in this series: 4,200–4,320 → 4,770–4,930 mutations/s.

Test plan

  • bun run lint, bun run typecheck, bun run test (the encoding and runtime tests compare calldata)

🤖 Generated with Claude Code

RetriggerConfidence Score: 5/5

The PR appears safe to merge; no actionable issues were found.

Summary

Replaces viem calls with cached ox functions when encoding execute and enqueue calldata.

  • The runtime encodes execute and enqueue calldata with cached ox functions.

Reviews (1) · Last reviewed commit: "perf(encoding): encode execute and enque..." · Reviewed by Greptile

…AbiFunction

viem's encodeFunctionData looks up the ABI item and hashes the selector on
every call: 14.6us for a one-mutation execute, against 3.5us for ox with
the function resolved once. The runtime encodes execute calldata for each
accepted mutation.

Counter benchmark, open loop at 8,000/s: 4,200-4,320 -> 4,770-4,930
mutations/s.
@kyscott18
kyscott18 merged commit 4fb7bb9 into main Oct 13, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant