Skip to content

Performance Profiler

The Performance Profiler measures and analyzes CodeBuddy’s operational performance — search latency, indexing throughput, memory usage, cache efficiency, and error rates. It provides both real-time alerts and on-demand performance reports.

MetricWindow sizeWhat it measures
Search latency100 samplesTime to complete a vector/hybrid search
Indexing throughput50 samplesFiles processed per second during indexing
Memory usage20 samplesHeap memory consumed by the extension
Cache hit rate100 samplesPercentage of queries served from cache
Error rate100 samplesPercentage of operations that fail

All metrics use a RollingAverage — a fixed-size window that evicts the oldest sample when full.

A performance report includes:

FieldCalculation
avgSearchLatencyMean of last 100 searches
p95SearchLatency95th percentile latency
avgIndexingThroughputMean files/sec throughput
avgMemoryUsageMean heap usage in MB
cacheHitRateMean cache hit percentage
errorRateMean error percentage

The profiler generates alerts when metrics cross thresholds:

Alert typeSeverityTrigger
HIGH_SEARCH_LATENCYwarningP95 search latency exceeds threshold
HIGH_MEMORY_USAGEwarningAverage memory exceeds system limit
HIGH_ERROR_RATEcriticalError rate exceeds acceptable threshold
LOW_THROUGHPUTinfoIndexing throughput drops below baseline

The profiler auto-configures operational parameters based on system capabilities:

System tierEmbedding batchCache sizeSearch timeoutIndexing concurrency
High (≥16 GB RAM, ≥8 cores)2010,00010s8
Medium (8–16 GB, 4–8 cores)105,00015s4
Low (<8 GB or <4 cores)52,00020s2

System detection uses os.totalmem() and os.cpus().length.

Wrap any operation to automatically record its performance:

const result = await profiler.measure("search", async () => {
return vectorDb.search(query);
});

This records:

  • Duration (milliseconds)
  • Memory delta (heap before vs. after)
  • Success/failure status

Failed operations are counted toward the error rate metric.