wrap RawAuctionData in Arc#4509
Open
ashleychandy wants to merge 7 commits into
Open
Conversation
Contributor
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 file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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