ari-performance-optimization
Performance optimization patterns for ARI's real-time processing
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
Menu
Performance optimization patterns for ARI's real-time processing
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
Based on SOC occupation classification
Discord slash commands, approval routing, channel policy, button interaction patterns for OpenClaw/ARI Discord integration
Obsidian vault integration patterns — vault-analyzer.ts, /ari-vault-* commands, morning briefing snippet, PARA structure, read-only enforcement
OpenClaw plugin development patterns — hooks, manifest structure, plugin SDK, APEX/CODEX enforcement
NOVA's P1 PayThePryce pipeline — market signal ingest, card detection, price monitoring, script generation, thumbnail generation, video assembly, approval gate
CHASE's P2 Pryceless Solutions pipeline — lead discovery, 5-criteria audit, LLM qualification, Prompt Forge 4-pass lock, demo generation, outreach approval gate
NOVA's thumbnail generation pipeline — Ideogram V3 via Fal.ai (primary) + DALL-E 3 fallback, 4-variant strategy, Pokemon TCG copyright rules,
| name | ari-performance-optimization |
| description | Performance optimization patterns for ARI's real-time processing |
| triggers | ["optimize performance","speed up ari","performance tuning","latency reduction"] |
Optimize ARI for maximum throughput and minimum latency in real-time agent operations.
| Metric | Target | Critical |
|---|---|---|
| Message latency | <100ms | <500ms |
| Sanitization | <10ms | <50ms |
| Agent response | <1s | <5s |
| Memory usage | <256MB | <512MB |
| Audit write | <5ms | <20ms |
// Use async event emission
eventBus.emit('event', data); // Fire and forget
// Batch related events
eventBus.emitBatch([
{ event: 'task:started', data: {...} },
{ event: 'audit:log', data: {...} }
]);
// Priority queues for critical events
eventBus.emitPriority('security:threat', data, 'high');
// Pre-compile regex patterns
const COMPILED_PATTERNS = PATTERNS.map(p => new RegExp(p, 'gi'));
// Early exit on first high-risk match
function fastScan(content: string): boolean {
for (const pattern of HIGH_RISK_PATTERNS) {
if (pattern.test(content)) return true;
}
return false;
}
// Use string methods when possible (faster than regex)
if (content.includes('DROP TABLE')) {
return { risk: 1.0, immediate: true };
}
// Stream large payloads
async function processLargeMessage(stream: Readable) {
for await (const chunk of stream) {
await processChunk(chunk);
}
}
// Clear references after use
function cleanup(task: Task) {
task.context = null;
task.result = null;
}
// Use WeakMap for caches
const cache = new WeakMap<Message, ProcessedResult>();
// Batch audit writes
const auditBuffer: AuditEvent[] = [];
const BATCH_SIZE = 100;
const FLUSH_INTERVAL = 1000;
function queueAudit(event: AuditEvent) {
auditBuffer.push(event);
if (auditBuffer.length >= BATCH_SIZE) {
flush();
}
}
setInterval(flush, FLUSH_INTERVAL);
// Parallel independent operations
const [guardianResult, plannerPrep] = await Promise.all([
guardian.assess(message),
planner.prepare(message.intent)
]);
// Cache frequent lookups
const trustCache = new LRUCache<string, TrustLevel>({
max: 1000,
ttl: 1000 * 60 * 5 // 5 minutes
});
# Increase memory limit
node --max-old-space-size=512 dist/index.js
# Enable V8 optimizations
node --optimize-for-size dist/index.js
# Use cluster mode for multi-core
node --experimental-cluster dist/index.js
# CPU profiling
node --cpu-prof dist/index.js
# Memory profiling
node --heap-prof dist/index.js
# Trace GC
node --trace-gc dist/index.js
// Built-in benchmarking
import { performance } from 'node:perf_hooks';
const start = performance.now();
await operation();
const duration = performance.now() - start;
logger.info({ operation: 'sanitize', duration }, 'Benchmark');
Key metrics to track: