wrap RawAuctionData in Arc#4509
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors the autopilot service to pass and store auction data using Arc and references rather than cloning, improving performance. A high-severity issue was identified in run_loop.rs where short-circuiting in a conditional check prevents prev_block from being updated when the auction changes, which could trigger redundant solver runs.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
|
This pull request has been marked as stale because it has been inactive a while. Please update this pull request or it will be automatically closed. |
Description
RawAuctionDatawas being cloned at multiple callsites, most expensively before the S3 upload background task and before DTO conversion, despite the original value remaining valid and unchanged. This PR wrapsRawAuctionDatainArcat the point of creation inSolvableOrdersCacheso it can be shared cheaply across the run loop, persistence layer, and solver request serialization without copying heap-allocated order and price data.Reopened from #4392 (closed by stale bot).
Benchmark results confirm the dominant win:
Arc::clone(~3 ns) vs a full DTO clone at 100 orders (~8.8 µs), roughly a 2900x difference on the sharing path. Conversion itself improves by ~48% at 10 orders by eliminating the pre-call clone callers previously needed to retain the original.Changes
RawAuctionDatainArcinsideSolvableOrdersCache::Inner;current_auction()now returnsOption<Arc<RawAuctionData>>instead of cloning the structCutAuction { id, auction }struct to carry theArcthroughcut_auction()->next_auction()without losing the auction IDupload_auction_to_s3to acceptArc<RawAuctionData>by value so thetokio::spawnclosure can take ownership of the reference without cloning the datadto::auction::from_domainanddto::order::from_domainto take&RawAuctionData/&Orderby reference; use.iter().cloned()where owned values are needed for the DTOQuote::from_domainand solver request serialization (dto::solve) to borrow rather than consumeCopyonSellTokenSourceandBuyTokenDestination(fieldless enums) to remove unnecessary borrows in conversion codelog_order_deltaas a generic helper; addlog_raw_auction_deltafor the run loop's raw-data path while preserving the existinglog_auction_deltafor other callsitesConversion: old vs new
Arc::clone vs dto.clone (100 orders)
dto.clone()Arc::clone~2900x difference. If the hot path is convert-once / share-many, wrapping in
Arcis the dominant win here.Raw output