test(network2): add new tcp-level benches#736
Conversation
📝 WalkthroughWalkthroughIntroduces Criterion benchmarking infrastructure for pallas-network2 protocol behavior. Adds dev dependencies and benchmark target configuration in Cargo.toml. Creates benchmark harness modules with MockChain, ResponderNode, and InitiatorNode for testing protocol interactions, along with three benchmark tests measuring handshake, chainsync, and blockfetch operations. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@pallas-network2/benches/harness/node.rs`:
- Around line 42-79: The event loop currently never terminates because
manager.poll_next().await returns None is ignored and
ResponderEvent::PeerDisconnected is a no-op; change the None branch to
break/return so the loop exits when the stream ends and handle
ResponderEvent::PeerDisconnected by breaking (or returning) as well so the task
can complete and return the collected events vector; update the logic around the
loop that collects events (the events variable and any return at the end of the
function) so after breaking you return or propagate the events, referencing
manager.poll_next(), ResponderEvent::PeerDisconnected, and the events Vec to
locate where to modify.
In `@pallas-network2/benches/protocol.rs`:
- Around line 11-18: The responder task started by
ResponderNode::bind().await.spawn() is being aborted (responder.abort()) but not
awaited, causing benchmark jitter; change the code to keep the JoinHandle
returned by spawn(), call responder.abort() and then await the join handle
(e.g., await the JoinHandle returned by spawn()) to ensure the task has fully
shut down before the next iteration; apply the same fix wherever
responder.abort() is used (the occurrences near InitiatorNode::connect_to(addr)
/ wait_for_handshake() and the other two locations referenced) so each aborted
responder is awaited to completion.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: ca98967f-c326-470a-b2fa-a1bd96346baa
📒 Files selected for processing (5)
pallas-network2/Cargo.tomlpallas-network2/benches/harness/chain.rspallas-network2/benches/harness/mod.rspallas-network2/benches/harness/node.rspallas-network2/benches/protocol.rs
Summary by CodeRabbit