perf: eliminate redundant read_dispair calls in try_into_call#2793
perf: eliminate redundant read_dispair calls in try_into_call#2793thedavidmeister wants to merge 3 commits into
Conversation
try_into_call previously called read_dispair 3 times (once directly and once inside each try_parse_rainlang call), totalling 12 sequential RPC round-trips just to read 4 immutable deployer addresses. Add parse_bytecode_with_dispair, which takes a pre-fetched DISPaiR and skips the read_dispair step. try_parse_rainlang becomes a wrapper around read_dispair + parse_bytecode_with_dispair. try_into_call now calls read_dispair once and passes the result to both parse calls via clone/move. RPC calls for a single deposit+addOrder submission: 14 → 6 (saves 8 sequential round-trips, ~2.4s at 300ms RTT). Adds assertions to test_into_add_order_call verifying both config.evaluable and tasks[0].evaluable carry the correct interpreter and store addresses from the single shared dispair read. Closes #2776 Co-Authored-By: Claude <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe rainlang parsing flow in AddOrderArgs is refactored to eliminate redundant DISPaiR RPC calls. A new parse_bytecode_with_dispair method accepts a pre-fetched DISPaiR instance, and try_into_call now fetches DISPaiR once, reusing cached interpreter and store values for both main and post-task evaluables. ChangesDISPaiR reuse in rainlang parsing
Estimated code review effort: 2 (Simple) | ~10 minutes Related issues: Addresses redundant Suggested reviewers: rainlanguage core maintainers familiar with 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Mark try_parse_rainlang as #[cfg(test)] — after the try_into_call refactor it is only called from tests, so the production build flags it as dead code under -D warnings. Co-Authored-By: Claude <noreply@anthropic.com>
Summary
try_into_callpreviously calledread_dispairthree times — once inline and once inside eachtry_parse_rainlangcall — totalling 12 sequential RPC round-trips just to read 4 immutable deployer addresses. At 300ms RTT (remote RPC) that is ~3.6s of avoidable latency.Changes
parse_bytecode_with_dispair: the parsing body extracted fromtry_parse_rainlang, takes a pre-fetchedDISPaiR(no additional dispair reads).try_parse_rainlangis now a thin wrapper:read_dispair+parse_bytecode_with_dispair. All existing tests remain unchanged.try_into_callcallsread_dispaironce, clones for the first parse, moves for the second parse, and extractsinterpreter/storeupfront.Result
RPC calls per
generate_deposit_and_add_order_calldatas(dispair portion):read_dispair)read_dispair)Total for a single deposit+addOrder: 14 → 6 sequential
eth_callround-trips, saving ~2.4s at 300ms RTT.Test
Adds assertions to
test_into_add_order_callverifying bothconfig.evaluable.interpreter/storeandtasks[0].evaluable.interpreter/storematch the expected interpreter/store addresses (and match each other). This mutation-validates that both evaluables receive the correct dispair from the single shared read.Closes #2776
Co-Authored-By: Claude noreply@anthropic.com
Summary by CodeRabbit