unrip/test-dashboard-speed.mjs
philipp fb547f24d9
All checks were successful
deploy / deploy (push) Successful in 48s
fix: scope inventory fetch by submission time window to prevent OOM
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
2026-06-16 17:17:19 +02:00

37 lines
2.1 KiB
JavaScript

import { createPostgresPool } from './src/lib/postgres.mjs';
import * as db from './src/lib/postgres.mjs';
async function measure(name, fn) {
const start = Date.now();
try {
await fn();
console.log(`[OK] ${name}: ${Date.now() - start}ms`);
} catch (e) {
console.log(`[ERR] ${name}: ${Date.now() - start}ms`, e.message);
}
}
async function main() {
const pool = createPostgresPool({ connectionString: process.env.POSTGRES_URL });
await Promise.all([
measure('loadLatestPortfolioMetric', () => db.loadLatestPortfolioMetric(pool)),
measure('loadLatestInventorySnapshot', () => db.loadLatestInventorySnapshot(pool)),
measure('loadLatestMarketPrice', () => db.loadLatestMarketPrice(pool)),
measure('loadRecentQuotes', () => db.loadRecentQuotes(pool, { limit: 100 })),
measure('loadSubmissionSummary', () => db.loadSubmissionSummary(pool)),
measure('loadSubmissionPage', () => db.loadSubmissionPage(pool, { page: 1, pageSize: 50 })),
measure('loadCurrentFundingObservations', () => db.loadCurrentFundingObservations(pool)),
measure('loadRecentDepositStatuses', () => db.loadRecentDepositStatuses(pool, { limit: 20 })),
measure('loadRecentTradeDecisions', () => db.loadRecentTradeDecisions(pool, { limit: 20 })),
measure('loadRecentExecuteTradeCommands', () => db.loadRecentExecuteTradeCommands(pool, { limit: 40 })),
measure('loadRecentExecutionResults', () => db.loadRecentExecutionResults(pool, { limit: 40 })),
measure('loadRecentQuoteOutcomes', () => db.loadRecentQuoteOutcomes(pool, { limit: 200 })),
measure('loadSuccessfulQuoteLifecycleEvidence', () => db.loadSuccessfulQuoteLifecycleEvidence(pool, { limit: 50 })),
measure('loadQuoteLifecycleRetentionSummary', () => db.loadQuoteLifecycleRetentionSummary(pool)),
measure('loadRecentQuoteLifecycleRollups', () => db.loadRecentQuoteLifecycleRollups(pool, { limit: 40 })),
measure('loadQuoteLifecycleStatistics', () => db.loadQuoteLifecycleStatistics(pool, { limit: 1000 })),
measure('loadRecentIntentRequests', () => db.loadRecentIntentRequests(pool, { limit: 50 })),
]);
process.exit(0);
}
main().catch(console.error);