Reuse serialized JSON auction orders - #4686
Conversation
|
Claude finished @jmg-duarte's task in 4m 3s —— View job PR Review: Reuse serialized JSON orders
Verdict: LGTM. Clean, well-documented, and well-tested refactor. No correctness issues found. What I checked
Notes
|
|
|
||
| // Collect valid solutions from all drivers | ||
| let solutions = self.fetch_solutions(&auction).await; | ||
| let solutions = self.fetch_solutions(&cut).await; |
There was a problem hiding this comment.
Minor (optional): orders_json is only needed by fetch_solutions, but single_run holds the whole cut: CutAuction — including the multi-MB serialized order buffer — until the function returns, i.e. across post_processing().await (DB writes) and settlement kickoff, even though the bytes are dead after this line.
Not a leak (it's bounded and freed at the end of each run), but since the whole point of this PR is shaving auction-sized allocations, you could drop it as soon as the request is built — e.g. pass orders_json into fetch_solutions by value instead of &cut, so the Arc is released when the solve requests are done. Feel free to ignore if the extra copy for the sub-second post-processing window isn't worth the churn.
MartinquaXD
left a comment
There was a problem hiding this comment.
I'm a bit worried that this complexity and fragility is not worth the relatively modest speed ups it brings.
| let written = from_domain(&auction, OrdersJson::new(&auction.orders).await); | ||
| let json = serde_json::to_string(&written).unwrap(); | ||
|
|
||
| let read: RawAuctionData = serde_json::from_str(&json).unwrap(); | ||
| assert_eq!(read.block, 42); | ||
| assert!(read.orders.is_empty()); |
There was a problem hiding this comment.
2 comments on this test:
- why are the orders empty? Wouldn't it make more sense to have at least 1 order in ther?
- this shows in a nutshell that
from_domain()is broken at the moment. Nothing guarantees that theOrdersJsonyou pass in actually matches theRawAuctionData::orders. This makes this code quite fragile IMO. Especially with JSON streaming and auction diffing coming up I feel like this will age super poorly. We'll keep all the complexity with very little upside since we can serialize JSON faster than the network can transfer it anyway.
|
Moving to draft, probably will be closed/archived but will keep it around so the idea isn't forgotten |
Description
Re-use serialized JSON orders for the /solve request, DB insert and S3 upload.
We can't re-use the full serialized auction, but we can re-use the orders array which gets quite big, cutting a full serialization section from the whole.
Changes
How to test
Tested in base staging, prod and mainnet prod
Base Prod:

Mainnet Prod:
