fix: make Writable trait async and remove the write_via_buf bridge function#6688
fix: make Writable trait async and remove the write_via_buf bridge function#6688hanabi1224 merged 1 commit intomainfrom
Conversation
WalkthroughConverts the write trait system from synchronous to asynchronous in the forest index module. Renames Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested reviewers
🚥 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 unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/db/car/forest/index/mod.rs (1)
759-762: Replace defensiveRuntime::new()with existingblock_onimport to avoid repeated runtime construction in quickcheck test loops.The
round_tripfunction is called repeatedly in quickcheck property generators; constructing atokio::runtime::Runtimeon each invocation is unnecessary overhead. Sincefutures::executor::block_onis already imported at line 658 and used successfully elsewhere in the file (lines 670, 697) for the sameAsyncWritepattern withVec<u8>, the refactor is safe:- let serialized = - write_to_vec(|v| tokio::runtime::Runtime::new()?.block_on(original.write_to(v))); + let serialized = write_to_vec(|v| block_on(original.write_to(v)));🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/db/car/forest/index/mod.rs` around lines 759 - 762, The round_trip helper currently constructs a new tokio::runtime::Runtime via Runtime::new()?.block_on(...) for serializing, which is costly in quickcheck loops; replace that call with the already-imported futures::executor::block_on to run original.write_to(v) (i.e., change Runtime::new()?.block_on(original.write_to(v)) to block_on(original.write_to(v))) in the write_to_vec invocation inside round_trip so you reuse the existing synchronous executor and avoid repeated runtime construction.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/db/car/forest/index/mod.rs`:
- Around line 759-762: The round_trip helper currently constructs a new
tokio::runtime::Runtime via Runtime::new()?.block_on(...) for serializing, which
is costly in quickcheck loops; replace that call with the already-imported
futures::executor::block_on to run original.write_to(v) (i.e., change
Runtime::new()?.block_on(original.write_to(v)) to
block_on(original.write_to(v))) in the write_to_vec invocation inside round_trip
so you reuse the existing synchronous executor and avoid repeated runtime
construction.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: ec3bad47-cc2a-4247-acf0-648389b0de13
📒 Files selected for processing (1)
src/db/car/forest/index/mod.rs
Codecov Report❌ Patch coverage is
Additional details and impacted files
... and 2 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
Summary of changes
Changes introduced in this pull request:
Writabletrait to avoid usingwrite_via_bufto bridgeWriteandAsyncWriteReference issue to close (if applicable)
Closes
Other information and links
Change checklist
Outside contributions
Summary by CodeRabbit