Skip to content

perf(syscalls): zero-copy private input API and migrate guests#865

Closed
diegokingston wants to merge 1 commit into
mainfrom
fix/private-input-zero-copy
Closed

perf(syscalls): zero-copy private input API and migrate guests#865
diegokingston wants to merge 1 commit into
mainfrom
fix/private-input-zero-copy

Conversation

@diegokingston

Copy link
Copy Markdown
Collaborator

Summary

get_private_input() used to end in slice.to_vec(), bulk-copying the whole private input every run even though the region is a fixed static mapping (0xFF000000) and a zero-copy path already existed (ef_io::read_input). This changes the API to return &'static [u8] and migrates the in-repo callers:

  • syscalls/src/syscalls.rs: return the from_raw_parts slice directly (host writes the mapping before execution and never mutates it, so the borrow is valid for the whole run); doc + SAFETY notes updated.
  • Guests migrated: ethrex (rkyv::from_bytes(input)), commit, commit_sum. memory needed no change (its try_into() resolves via TryFrom<&[u8]>).
  • syscalls/README.md API table updated.

Measured guest cycles (cli execute --cycles, deterministic)

Fixture Baseline Patched Delta
ethrex_empty_block 994,639 980,441 −1.4%
ethrex_simple_tx 1,791,453 1,723,120 −3.8%
ethrex_10_transfers 6,810,436 6,743,623 −1.0%

Savings exceed the single-syscall-copy model (~3 instrs per 8 input bytes): the owned Vec also forced downstream clones in the guest's rkyv deserialization layers, which are gone too.

Verification

  • riscv64 guest-target cross-checks: lambda-vm-syscalls, commit, commit_sum, memory, and the full ethrex guest — all clean.
  • No host-workspace crate uses this API (crypto/ethrex-crypto uses only ecsm_mul/keccak_permute).

Follow-up (not in this PR)

  • bench_vs/lambda/recursion (untracked WIP guest) needs the same call-site tweak (postcard::from_bytes(&blob)(blob)) once this lands.
  • Pre-existing repo quirk surfaced while verifying: syscalls/ is not in the root workspace's exclude, so cargo check from its own dir errors ("believes it's in a workspace when it's not"); an empty [workspace] table in its Cargo.toml would fix it.

@diegokingston

Copy link
Copy Markdown
Collaborator Author

Closing in favor of the zero-copy private-input implementation already on feat/hint-table (ead3da8a — additive get_private_input_slice(), no API break). Measured numbers in this PR's body still hold for that approach (−3.8% cycles on ethrex 1-tx, ~66k/run).

@diegokingston
diegokingston deleted the fix/private-input-zero-copy branch July 24, 2026 22:15
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