[object Object]

← back to Bertha

chore(alshi-dash): update 1 file (.js) [+12/-12]

8acefa6ad9b960ddf7c9c11ac6591bd74852870f · 2026-03-03 00:12:28 +0000 · DW Commit Agent

Files touched

Diff

commit 8acefa6ad9b960ddf7c9c11ac6591bd74852870f
Author: DW Commit Agent <commit-agent@dw-agents.com>
Date:   Tue Mar 3 00:12:28 2026 +0000

    chore(alshi-dash): update 1 file (.js) [+12/-12]
---
 kalshi-dash/server.js | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/kalshi-dash/server.js b/kalshi-dash/server.js
index 6d7d97d..88fc2dd 100644
--- a/kalshi-dash/server.js
+++ b/kalshi-dash/server.js
@@ -267,7 +267,7 @@ function monteCarloSimulation(params, iterations = 10000) {
 // PARALLEL PROCESSING — run CPU-heavy tasks across cores
 // ══════════════════════════════════════════════════════
 const CPU_CORES = Math.max(2, os.cpus().length);
-const WORKER_POOL_SIZE = Math.min(4, CPU_CORES - 1); // Leave 1 core for main thread
+const WORKER_POOL_SIZE = Math.min(12, CPU_CORES - 2); // Use up to 14 cores, leave 2 for OS + other services
 
 function runInParallel(tasks, workerFn) {
   return Promise.all(tasks.map(task => {
@@ -282,7 +282,7 @@ function runInParallel(tasks, workerFn) {
 }
 
 // Batch process markets in parallel chunks
-async function parallelMarketAnalysis(markets, analysisFunc, batchSize = 25) {
+async function parallelMarketAnalysis(markets, analysisFunc, batchSize = 50) {
   const results = [];
   const batches = [];
   for (let i = 0; i < markets.length; i += batchSize) {
@@ -4873,7 +4873,7 @@ const server = http.createServer(async (req, res) => {
 // ══════════════════════════════════════════════════════════════
 
 const KEN_DB = 'postgresql://dw_admin:DW2024SecurePass@127.0.0.1:5432/dw_unified';
-const kenPool = new pg.Pool({ connectionString: KEN_DB, max: 5, idleTimeoutMillis: 30000 });
+const kenPool = new pg.Pool({ connectionString: KEN_DB, max: 20, idleTimeoutMillis: 30000 });
 async function kenQ(text, params) { return kenPool.query(text, params); }
 
 // ── Mutable scan/pipeline intervals (adjustable via Settings UI) ──
@@ -5507,8 +5507,8 @@ const NEWS_FEEDS = [
 
 async function scrapeAllNewsFeeds() {
   const allArticles = [];
-  // Process feeds in batches of 5 concurrently for speed
-  const batchSize = 5;
+  // Process feeds in batches of 15 concurrently for speed (maxed for 16 cores)
+  const batchSize = 15;
   for (let i = 0; i < NEWS_FEEDS.length; i += batchSize) {
     const batch = NEWS_FEEDS.slice(i, i + batchSize);
     const results = await Promise.allSettled(
@@ -5517,7 +5517,7 @@ async function scrapeAllNewsFeeds() {
     for (const result of results) {
       if (result.status === 'fulfilled') allArticles.push(...result.value);
     }
-    await new Promise(r => setTimeout(r, 300)); // small pause between batches
+    await new Promise(r => setTimeout(r, 100)); // minimal pause between batches
   }
   return allArticles;
 }
@@ -5846,8 +5846,8 @@ async function redditIntelligenceLoop() {
     // Get tracking config from DB
     const { rows: trackers } = await kenQ('SELECT * FROM ken_reddit_tracking WHERE enabled = true');
 
-    // Process tracked subreddits in parallel batches of 5 (58 serial × 2s = too slow)
-    const TRACKER_BATCH = 5;
+    // Process tracked subreddits in parallel batches of 12 (maxed for 16 cores)
+    const TRACKER_BATCH = 12;
     for (let i = 0; i < trackers.length; i += TRACKER_BATCH) {
       const batch = trackers.slice(i, i + TRACKER_BATCH);
       const results = await Promise.allSettled(
@@ -5874,7 +5874,7 @@ async function redditIntelligenceLoop() {
           }
         }
       }
-      await new Promise(r => setTimeout(r, 1500)); // 1.5s between batches
+      await new Promise(r => setTimeout(r, 500)); // 0.5s between batches (was 1.5s)
     }
 
     // Also scrape hot posts from key subreddits for general intelligence
@@ -5911,8 +5911,8 @@ async function redditIntelligenceLoop() {
       // ── General sentiment ──
       'news', 'OutOfTheLoop', 'AskReddit', 'TrueReddit', 'dataisbeautiful',
     ];
-    // Process subreddits in parallel batches of 5 (75+ subs × 2s serial = too slow)
-    const REDDIT_BATCH = 5;
+    // Process subreddits in parallel batches of 12 (maxed for 16 cores)
+    const REDDIT_BATCH = 12;
     for (let i = 0; i < hotSubs.length; i += REDDIT_BATCH) {
       const batch = hotSubs.slice(i, i + REDDIT_BATCH);
       const results = await Promise.allSettled(batch.map(sub => scrapeSubredditHot(sub, 8)));
@@ -5931,7 +5931,7 @@ async function redditIntelligenceLoop() {
           }
         }
       }
-      await new Promise(r => setTimeout(r, 1500)); // 1.5s between batches
+      await new Promise(r => setTimeout(r, 500)); // 0.5s between batches (was 1.5s)
     }
     console.log(`[Ken] Reddit hot: ${hotSubs.length} subreddits across 10 categories`);
     logMemory('after-reddit');

← bb378cf chore(alshi-dash,kalshi-dash): update 4 files (.js) [+258/-1  ·  back to Bertha  ·  chore(next): update 1 file (no-ext) [-4846] 537f34b →