Performance Profiler
Measures runtime performance — search latency, indexing throughput, memory, cache hit rate, error rate. Adapts operational parameters to your system tier.
Tracked metrics
Section titled “Tracked metrics”Each metric is a RollingAverage — fixed window, oldest sample evicts when full.
| Metric | Window | Measures |
|---|---|---|
| Search latency | 100 samples | Time to complete a vector/hybrid search |
| Indexing throughput | 50 samples | Files/sec during indexing |
| Memory usage | 20 samples | Heap consumed by the extension |
| Cache hit rate | 100 samples | % of queries served from cache |
| Error rate | 100 samples | % of operations that fail |
Reports
Section titled “Reports”getMetrics() returns:
| Field | Meaning |
|---|---|
avgSearchLatency | Mean of last 100 searches |
p95SearchLatency | 95th percentile latency |
avgIndexingThroughput | Mean files/sec |
avgMemoryUsage | Mean heap (MB) |
cacheHitRate | Mean cache hit percentage |
errorRate | Mean error percentage |
Alerts
Section titled “Alerts”| Alert | Severity | Trigger |
|---|---|---|
HIGH_SEARCH_LATENCY | warn | P95 search latency > threshold |
HIGH_MEMORY_USAGE | warn | Average memory > system limit |
HIGH_ERROR_RATE | critical | Error rate > acceptable threshold |
LOW_THROUGHPUT | info | Indexing throughput < baseline |
Adaptive configuration
Section titled “Adaptive configuration”At startup, os.totalmem() + os.cpus().length place the system into a tier. Operational parameters auto-tuned per tier:
| Tier | Embedding batch | Cache size | Search timeout | Indexing concurrency |
|---|---|---|---|---|
| High (≥16 GB RAM, ≥8 cores) | 20 | 10 000 | 10 s | 8 |
| Medium (8–16 GB, 4–8 cores) | 10 | 5 000 | 15 s | 4 |
| Low (<8 GB or <4 cores) | 5 | 2 000 | 20 s | 2 |
Measurement API
Section titled “Measurement API”const result = await profiler.measure("search", async () => vectorDb.search(query));Records duration (ms), memory delta (heap before → after), and success/failure. Failures increment the error-rate metric.