Home🎛️ Control🖥️ GPU FleetArchitecture⚡ Performance💰 Costs

⚡ Performance Engineering

Pipeline optimization: caching, parallelism, Rust migration, multi-region GPU distribution.

Sharded Execution

StepShard StrategyWorkersBeforeAfter
Gene EnrichmentChunks of 10 genes5 parallel shards × 10 threads each~45s sequential~5s
FRSI ScoringBy cancer type4 parallel (1 per cancer)~30s sequential~8s
FRSI DDB WritesPer cancer shard10 threaded writers per shard89 sequential~2s
GPU DockingBy region5 regions parallel (watchdog spread)1 region, 129 queued5 regions, distributed
Rust Enrichment (Fargate)20 async taskstokio JoinSetn/a~5s cold, <1s cached

Nightly Pipeline Performance

OptimizationBeforeAfterTechnique
DDB scans5× full table scan1× single scanPre-load all_heroes, pass to steps
Gene enrichment HTTP534 new TCP connectionsConnection pooling (keep-alive)requests.Session()
Enrichment workers4 threads10 threadsThreadPoolExecutor
Enrichment batch20 genes/night50 genes/nightRaised BATCH_SIZE
HTTP timeout12s (blocks thread)8s (fail fast)Lower timeout + retry
DDB writes per gene3 sequential3 parallelThreadPoolExecutor per gene
FRSI DDB writes89 sequential update_item10 threadedThreadPoolExecutor
Lambda timeout120s (crashing)900sConfiguration fix
Total nightly>3 min (timeout)~45sAll combined

Enrichment Cache (DDB)

Table: cortex-enrichment-cache

Key: {api}:{gene} (e.g. chembl:BRAF)

TTL: 7 days (DynamoDB auto-expiry enabled)

APIs cached: UniProt, ChEMBL, OpenTargets

Impact: First run ~5s (cold), subsequent runs <1s (all cache hits)

Cost: ~$0.01/month (89 genes × 3 APIs = 267 items, each <1KB)

Rust Migration (cortex-rs)

ModuleStatusConcurrencySpeed vs Python
Gene Enrichment✅ Scaffolded20 async tasks (tokio)~10× faster
WatchdogPython (deployed)Sequential per regionFine at 5 regions
FRSI ScoringMigratable (just math)—~5× faster
FGAO / RDKitKeep Python—Needs RDKit bindings
GCN TrainingKeep Python—numpy is fast enough

Rust Enrichment Architecture

┌─────────────────────────────────────────────────┐
│           cortex-rs enrichment module            │
├─────────────────────────────────────────────────┤
│                                                  │
│  scan_unenriched_heroes() ──→ Vec<String>       │
│         │                                        │
│         ▼ (20 concurrent tasks)                  │
│  ┌──────────────────────────────────────┐       │
│  │  fetch_cached(ddb, http, api, gene)  │       │
│  │    ├── cache_get() → HIT → return    │       │
│  │    └── MISS → fetch API → cache_put  │       │
│  └──────────────────────────────────────┘       │
│         │                                        │
│         ▼ (parallel DDB writes)                  │
│  write_enrichment() ──→ cortex-heroes table     │
│                                                  │
└─────────────────────────────────────────────────┘

GPU Fleet — Multi-Region Parallel Distribution

FeatureLogicImpact
Parallel spreadIf 1 region has >3 queued + others idle → distribute129 jobs → 5 regions in 1 cycle
Stuck rerouteRUNNABLE >15min → cancel + reroute to best regionNo more 69-min waits
Region scoringTrack success/fail rate per region, pick lowest failureAuto-avoids bad capacity zones
Spread capKeep 4 in source, spread up to 60 per cycleFleet fully utilized in 1 cycle
DedupCross-region duplicate detectionNo wasted GPU time

Watchdog Performance

MetricValue
Execution time~3s per cycle
API calls per cycle15 (3 per region × 5 regions)
ScheduleEvery 5 min (master), every 10 min (failover)
Monthly cost~$0.50 (288 invocations/day × 3s × 256MB)

Infrastructure Decision: ECS Fargate vs Kubernetes

ECS Fargate (current)K8s (EKS)
Ops overheadZero — no clusterCluster, nodes, upgrades
Cost at our scale~$0.002/run$75/mo minimum (control plane)
Spin-up~10s~10s (warm nodes)
GPU supportEC2 mode (Batch)Full pod scheduling
Already deployed✅ cortex-fargate existsWould need setup
Multi-regionSeparate task per regionFederation complexity

Decision: Stay on ECS. Migrate to EKS only when:

Next Optimizations (Burst Mode)

OptimizationImpactWhen
Rust nightly binaryFull pipeline in ~10sBurst mode session
NVIDIA DGX Cloud burst100+ concurrent docking jobsTomorrow
Google Cloud TPUGCN training accelerationTomorrow
Sharded Lambda fan-out5 parallel workers × 18 genes eachAt 200+ heroes
S3 Select for large datasetsSkip full TCGA downloadsAt FRSI v0.3