All checks were successful
deploy / deploy (push) Successful in 48s
Instead of fetching up to 50k inventory snapshots (~442MB), scope the query to only the time range of the current submission batch with a 15-minute buffer. For a typical 1-hour batch this drops from 50k rows to ~300 rows, well within the 1280Mi pod memory limit. The coalesced_at_idx on intent_inventory_snapshots covers the BETWEEN clause so this remains efficient. Proof: history-writer OOM kills from refreshQuoteOutcomes inventory fetch Assumptions: 15min buffer covers the attribution window for all submissions Still fake: heuristic gap outcomes may attribute trades imprecisely
14 lines
574 B
JavaScript
14 lines
574 B
JavaScript
import { deriveQuoteOutcomeRecords } from './src/core/quote-outcomes.mjs';
|
|
const submissions = Array.from({length: 2000}).map((_, i) => ({
|
|
quote_id: 'q' + i,
|
|
submitted_at: new Date().toISOString(),
|
|
expected_inventory_delta: { asset1: 10n }
|
|
}));
|
|
const inventorySnapshots = Array.from({length: 5000}).map((_, i) => ({
|
|
inventory_id: 'i' + i,
|
|
observed_at: new Date(Date.now() + i * 1000).toISOString(),
|
|
asset_balances: { asset1: BigInt(i * 10) }
|
|
}));
|
|
console.time('derive');
|
|
deriveQuoteOutcomeRecords({ submissions, inventorySnapshots });
|
|
console.timeEnd('derive');
|