fix(polymarket): bound cold-start retained values - #86
Conversation
📝 WalkthroughWalkthroughGamma market discovery now filters configured symbols and enforces per-lane limits. Trade collection validates owned response data, preserves full trade payloads, and target processing drains owned entries while retaining accurate health metrics. ChangesPolymarket collector
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ 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.
🧹 Nitpick comments (1)
rust_hft/tools/collector/src/polymarket_raw.rs (1)
1153-1160: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick winPrefer in-place filtering to avoid vector reallocation.
Since
pageis already owned, you can use.retain()to filter out non-objects in place. This avoids allocating a new vector and fits perfectly with the PR's goal of efficiently consuming the raw payloads.♻️ Proposed fix using `retain`
-fn object_rows(page: Vec<Value>) -> (Vec<Value>, u64) { - let page_len = page.len(); - let objects = page - .into_iter() - .filter(|value| value.is_object()) - .collect::<Vec<_>>(); - let rejected = u64::try_from(page_len - objects.len()).unwrap_or(u64::MAX); - (objects, rejected) -} +fn object_rows(mut page: Vec<Value>) -> (Vec<Value>, u64) { + let page_len = page.len(); + page.retain(Value::is_object); + let rejected = u64::try_from(page_len - page.len()).unwrap_or(u64::MAX); + (page, rejected) +}🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@rust_hft/tools/collector/src/polymarket_raw.rs` around lines 1153 - 1160, Update object_rows to filter the owned page in place with retain, removing non-object values without collecting into a new vector. Preserve the rejected count based on the original and retained lengths, then return the filtered page and count.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@rust_hft/tools/collector/src/polymarket_raw.rs`:
- Around line 1153-1160: Update object_rows to filter the owned page in place
with retain, removing non-object values without collecting into a new vector.
Preserve the rejected count based on the original and retained lengths, then
return the filtered page and count.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 32af1b76-9078-489f-a052-d0832c630c13
📒 Files selected for processing (1)
rust_hft/tools/collector/src/polymarket_raw.rs
Change contract
Reduce the Polymarket reference collector cold-start retained Value peak by retaining only configured target markets and moving owned market/trade payloads through the cycle, while preserving output schema, ordering, pagination, limits, and fail-closed completeness.
Out of scope
Dependency or merge order
None. This branch is rebased onto main after #85 (672M/768M calibration).
Focused validation
Rollout/rollback impact
The collector emits the same records and health target count with a lower cold-start memory peak. Rollout requires a new Linux collector artifact and the existing shadow gate. Rollback is a normal revert to the previous collector artifact; no data or configuration migration is required.
Summary by CodeRabbit