Idiomark - Performance Characteristics
Last Updated: 2026-02-11 Maintainer: Performance Team
Table of Contents
- Overview
- Performance Targets
- Benchmarks
- Bottlenecks
- Optimization Strategies
- Profiling Guide
- Capacity Planning
Overview
This document describes the performance characteristics of the Idiomark system. It is intended for engineers optimizing performance and planning capacity.
Performance Philosophy
- Measure First - Never optimize without profiling
- User-Perceived Performance - Optimize for what users experience
- Cost-Performance Tradeoff - Balance LLM costs with quality
- Incremental Improvement - Small, measurable wins over big rewrites
Key Performance Indicators
| KPI | Target | Current | Status |
|---|---|---|---|
| CLI Extract Time (1000 items) | < 30s | 18s | ✅ |
| API Response Time (p95) | < 500ms | 234ms | ✅ |
| Analysis Accuracy | > 0.8 confidence | 0.85 | ✅ |
| Cache Hit Rate | > 70% | 87% | ✅ |
| Adapter Fetch Time | < 5s/100 items | 2.3s | ✅ |
Performance Targets
Latency Targets
By Component:
| Component | Target (p50) | Target (p95) | Target (p99) |
|---|---|---|---|
| API - Extract | 10s | 25s | 45s |
| API - Analyze | 5s | 12s | 20s |
| API - Validate | 100ms | 300ms | 500ms |
| CLI - Extract | 15s | 30s | 60s |
| Adapter Fetch | 2s | 4s | 8s |
| Normalization | 50ms | 100ms | 200ms |
| LLM Analysis | 3s | 8s | 15s |
| Cache Read | 1ms | 5ms | 10ms |
| Cache Write | 2ms | 10ms | 20ms |
Throughput Targets
| Metric | Target | Current | Status |
|---|---|---|---|
| API Requests/sec | 1000 | 450 | ⚠️ |
| Worker Jobs/min | 500 | 320 | ⚠️ |
| Concurrent Extractions | 100 | 45 | ⚠️ |
| Adapter Requests/sec | 5000 | 2800 | ⚠️ |
Resource Utilization
| Resource | Target | Alert Threshold |
|---|---|---|
| API Server CPU | < 60% | > 80% |
| Worker CPU | < 70% | > 90% |
| Memory | < 70% | > 85% |
| Database Connections | < 50% | > 80% |
| Cache Memory | < 60% | > 80% |
Benchmarks
Extraction Performance
By Sample Size
| Sample Size | Total Time | Fetch Time | Analysis Time | Confidence |
|---|---|---|---|---|
| 100 | 3.2s | 1.1s | 2.1s | 0.72 |
| 500 | 12.4s | 4.2s | 8.2s | 0.84 |
| 1000 | 24.8s | 8.5s | 16.3s | 0.87 |
| 2500 | 58.3s | 21.2s | 37.1s | 0.89 |
| 5000 | 112.7s | 42.5s | 70.2s | 0.91 |
Benchmark Command:
pnpm benchmark --scenario extraction --samples 1000 --iterations 10
By Platform
| Platform | 100 items | 500 items | 1000 items |
|---|---|---|---|
| GitHub | 2.1s | 8.4s | 16.7s |
| 2.8s | 11.2s | 22.3s | |
| 3.5s | 14.1s | 28.2s | |
| Discord | 2.5s | 10.0s | 20.0s |
Analysis Performance
By Provider
| Provider | Model | 10k chars | 50k chars | 100k chars | Cost |
|---|---|---|---|---|---|
| Anthropic | Claude 3.5 Sonnet | 4.2s | 18.3s | 37.1s | $0.012 |
| OpenAI | GPT-4o | 3.8s | 16.5s | 33.2s | $0.015 |
| Mock | - | < 1s | < 1s | < 1s | $0 |
Chunking Performance
| Text Size | Without Chunking | With Chunking | Speedup |
|---|---|---|---|
| 15k chars | 4.2s | 4.2s | 1.0x |
| 50k chars | 18.3s | 21.1s | 0.87x |
| 100k chars | Timeout | 42.3s | 2.0x+ |
| 250k chars | Timeout | 98.2s | 3.0x+ |
Note: Chunking adds overhead but enables processing large texts.
Cache Performance
Hit Rate by Workload
| Workload | Hit Rate | Miss Rate | Avg Latency |
|---|---|---|---|
| Repeated Queries | 94% | 6% | 45ms |
| New Queries | 12% | 88% | 2.1s |
| Mixed | 67% | 33% | 723ms |
Cache Size vs Hit Rate
| Cache Size | Hit Rate | Memory Used |
|---|---|---|
| 100 keys | 23% | 12MB |
| 1,000 keys | 45% | 120MB |
| 10,000 keys | 68% | 1.2GB |
| 100,000 keys | 87% | 12GB |
Adapter Performance
GitHub Adapter
| Operation | 100 items | 500 items | 1000 items |
|---|---|---|---|
| Fetch | 1.1s | 4.2s | 8.5s |
| Normalize | 45ms | 180ms | 350ms |
| Total | 1.15s | 4.4s | 8.9s |
Rate Limit Behavior:
| Tier | Limit | Reset Time | Full Batch Time |
|---|---|---|---|
| Unauthenticated | 60/hr | 1 hour | 60+ hours |
| Authenticated | 5000/hr | 1 hour | < 1 hour |
Twitter Adapter
| Operation | Free | Basic | Pro |
|---|---|---|---|
| Rate Limit | 15/15min | 100/day | 300/3hr |
| 100 items | 100+ min | 15 min | 5 min |
| 1000 items | 1000+ min | 150 min | 50 min |
Bottlenecks
Current Bottlenecks (Ordered by Impact)
1. LLM API Latency (~60% of extract time)
Impact: High Affected: All extractions Root Cause: LLM API calls are network-bound and have variable latency
Mitigation:
- Use faster models for initial analysis
- Implement streaming analysis
- Cache intermediate results
- Consider local models for common patterns
2. Adapter Rate Limiting (~25% of extract time)
Impact: Medium-High Affected: Large extractions Root Cause: Platform API rate limits
Mitigation:
- Better caching reduces API calls
- Parallel extraction across sources
- Rate limit-aware scheduling
- Implement proxy services for high-volume needs
3. Sequential Processing (~10% of extract time)
Impact: Medium Affected: Multi-source extractions Root Cause: Sources are processed sequentially
Mitigation:
- Parallel adapter execution
- Independent job queuing per source
- Aggressive parallelization for independent operations
4. Memory Usage for Large Texts (~5% impact)
Impact: Low-Medium Affected: Very large content sets Root Cause: All content loaded into memory
Mitigation:
- Streaming content processing
- Chunk-based processing
- Memory-mapped files for very large datasets
Identified vs Actual Bottlenecks
Sometimes the bottleneck is not where expected:
| Expected Bottleneck | Actual Bottleneck | Resolution |
|---|---|---|
| LLM analysis | Adapter fetching | Implemented caching |
| Cache I/O | Network latency | Reduced cache lookups |
| Processing | Garbage collection | Optimized object allocation |
Optimization Strategies
High-Impact Optimizations
1. Parallel Extraction
Before: Sequential source processing
for (const source of sources) {
await extractFromSource(source);
}
After: Parallel source processing
await Promise.all(sources.map(source =>
extractFromSource(source)
));
Impact: 3-5x faster for multiple sources
2. Aggressive Caching
Strategy: Cache at multiple levels
// L1: In-memory (process)
const l1 = inMemoryCache.get(key);
if (l1) return l1;
// L2: Redis (cross-process)
const l2 = await redis.get(key);
if (l2) {
inMemoryCache.set(key, l2);
return l2;
}
// L3: Compute and cache
const result = await compute();
await redis.set(key, result);
inMemoryCache.set(key, result);
return result;
Impact: 70-90% cache hit rate for common queries
3. Batching Adapter Requests
Before: One API call per item
for (const id of itemIds) {
await fetch(`/items/${id}`);
}
After: Batch API calls
for (const batch of chunks(itemIds, 100)) {
await fetch(`/items?ids=${batch.join(',')}`);
}
Impact: 5-10x faster for bulk operations
Medium-Impact Optimizations
4. Lazy Loading
Strategy: Load adapters only when needed
// Lazy load adapter
const adapter = await import(`@idiomark/adapter-${platform}`);
Impact: 30% faster CLI startup time
5. Streaming Analysis
Strategy: Process chunks as they arrive
for await (const chunk of streamChunks(text)) {
const partial = await analyze(chunk);
emit('progress', partial);
}
Impact: Better UX, 20% faster perceived latency
6. Connection Pooling
Strategy: Reuse HTTP connections
const agent = new https.Agent({
keepAlive: true,
maxSockets: 50,
maxFreeSockets: 10
});
fetch(url, { agent });
Impact: 15-25% faster for repeated requests
Low-Impact Optimizations
7. String Optimization
Before: String concatenation in loops
let result = '';
for (const item of items) {
result += item.text;
}
After: Array join
const parts = [];
for (const item of items) {
parts.push(item.text);
}
const result = parts.join('');
Impact: 5-10% faster for large texts
8. Object Reuse
Strategy: Reuse objects instead of creating new ones
// Object pool for frequent operations
const objectPool = new Map<string, NormalizedContent>();
function getOrCreate(id: string): NormalizedContent {
if (!objectPool.has(id)) {
objectPool.set(id, createNormalizedContent());
}
return objectPool.get(id)!;
}
Impact: 10-20% less GC pressure
Profiling Guide
Built-in Profiling
CLI Profiling
# Profile extraction
idiomark extract --github --sample-size 1000 --profile
# Output:
# Fetch: 8.5s (34%)
# Normalize: 0.35s (1%)
# Analyze: 16.3s (65%)
# Total: 25.15s
API Profiling
# Enable profiling
idiomark-ops profile enable --service api
# Generate report
idiomark-ops profile report --last 1h
# Output:
# POST /extract: 234ms p95 (45% requests)
# POST /analyze: 5.6s p95 (30% requests)
# GET /health: 5ms p95 (25% requests)
Node.js Profiling
CPU Profiling
# Start with profiling
node --prof --logfile=%p.prof.js $(which idiomark) extract --github
# Process profile
node --prof-process isolate-0xnnnn.prof > processed.txt
# Visualize
0x --profile-path isolate-0xnnnn.prof --kernel
Heap Profiling
# Take heap snapshot
node --heap-prof script.js
# Analyze heap
clinic heapprofiler -- script.js
Flame Graphs
# Generate flame graph
0x -p $(pgrep node) --output flamegraph.svg
# Analyze hot paths
# Look for wide bars (most time spent)
# Look for deep stacks (many function calls)
Database Profiling
Slow Queries
# Find slow queries
idiomark-ops db slow-queries --threshold 1s
# Output:
# SELECT * FROM content WHERE ... : 2.3s (4523 rows)
# UPDATE cache SET ... : 1.8s
Query Analysis
EXPLAIN ANALYZE
SELECT * FROM normalized_content
WHERE platform = 'github' AND timestamp > '2025-01-01';
Cache Profiling
Cache Stats
# Real-time cache monitoring
idiomark-ops cache monitor
# Output:
# Hit Rate: 87.3%
# Avg Latency: 2.3ms
# Evictions/min: 45
# Memory: 1.2GB / 4GB
Cache Key Analysis
# Find hot keys
idiomark-ops cache hot-keys --top 100
# Find unused keys
idiomark-ops cache unused --older-than 7d
Capacity Planning
Scaling Model
Request Growth
Assuming 20% month-over-month growth:
| Month | Requests/day | Peak RPS | Nodes Needed |
|---|---|---|---|
| Current | 100K | 50 | 5 |
| +1 month | 120K | 60 | 6 |
| +3 months | 173K | 86 | 9 |
| +6 months | 299K | 150 | 15 |
| +12 months | 891K | 445 | 45 |
Storage Growth
| Data Type | Per User | Growth Rate | 12 Month Projection |
|---|---|---|---|
| Idiomark Files | 50KB | 20% MoM | 500GB |
| Cache Data | 100KB | 30% MoM | 2TB |
| Logs | 10MB/day | 10% MoM | 4TB |
Scaling Thresholds
Horizontal Scaling Triggers
| Metric | Trigger | Action |
|---|---|---|
| CPU | > 70% sustained | Add replicas |
| Memory | > 75% sustained | Add replicas or upgrade |
| Queue Depth | > 1000 | Add workers |
| Connections | > 80% max | Scale database |
Vertical Scaling Triggers
| Metric | Trigger | Action |
|---|---|---|
| Single Node CPU | > 90% | Upgrade instance type |
| I/O Bound | High I/O wait | Move to SSD-optimized |
| Memory Per Request | Growing | Profile for leaks |
Cost Modeling
LLM Cost Per Extraction
| Sample Size | Anthropic | OpenAI | Mixed |
|---|---|---|---|
| 100 | $0.008 | $0.012 | $0.010 |
| 500 | $0.032 | $0.048 | $0.040 |
| 1000 | $0.064 | $0.096 | $0.080 |
| 5000 | $0.32 | $0.48 | $0.40 |
Cost Optimization Strategies:
- Use smaller models for initial analysis
- Cache aggressively
- Batch analyses when possible
- Consider local models for high-volume needs
Infrastructure Cost Breakdown
| Component | Monthly Cost | Per 1K Requests |
|---|---|---|
| API Servers | $1,200 | $0.24 |
| Workers | $800 | $0.16 |
| Database | $600 | $0.12 |
| Cache | $300 | $0.06 |
| LLM APIs | $2,000 | $0.40 |
| Total | $4,900 | $0.98 |
Performance Testing
Load Testing
K6 Configuration
// load-test.js
import http from 'k6/http';
import { check } from 'k6';
export let options = {
stages: [
{ duration: '2m', target: 50 }, // Ramp up
{ duration: '5m', target: 50 }, // Sustained
{ duration: '2m', target: 100 }, // Ramp up
{ duration: '5m', target: 100 }, // Sustained
{ duration: '2m', target: 0 }, // Ramp down
],
thresholds: {
http_req_duration: ['p(95)<500'], // 95% under 500ms
http_req_failed: ['rate<0.01'], // <1% errors
},
};
export default function() {
const response = http.post(
'https://api.idiomark.org/v1/analyze',
JSON.stringify({
texts: ['Sample text']
}),
{ headers: { 'Content-Type': 'application/json' }}
);
check(response, {
'status is 200': (r) => r.status === 200,
'response time < 500ms': (r) => r.timings.duration < 500,
});
}
Run Load Test:
k6 run load-test.js
Stress Testing
Find Breaking Point
# Gradually increase load until failure
idiomark-ops stress test --start 10 --increment 10 --max 1000
# Monitor for:
# - Error rate spike
# - Latency increase
# - Service crashes
Soak Testing
Extended Load
# Run for 24 hours at 50% capacity
idiomark-ops soak-test --duration 24h --load 50
# Monitor for:
# - Memory leaks
# - Connection pool exhaustion
# - Degradation over time
Performance Monitoring
Real-Time Monitoring
Metrics Dashboard
URL: https://grafana.idiomark.org/d/performance
Key Panels:
- Request latency heatmap
- Error rate by endpoint
- Adapter health dashboard
- LLM cost tracking
- Cache performance
Alerting
| Metric | Warning | Critical |
|---|---|---|
| p95 Latency | > 500ms | > 1000ms |
| Error Rate | > 0.5% | > 1% |
| Queue Depth | > 1000 | > 5000 |
| Cache Hit Rate | < 60% | < 40% |
Performance Regression Detection
Baseline Comparison
# Compare current performance with baseline
idiomark-ops perf compare --baseline yesterday
# Output:
# Extract 1000 items: 18.2s vs 24.1s (↑24% improvement)
# API p95 latency: 234ms vs 312ms (↑25% improvement)
# Cache hit rate: 87% vs 82% (↑6% improvement)
For questions about performance, contact: perf@idiomark.org