Skip to main content

Idiomark - Performance Characteristics

Last Updated: 2026-02-11 Maintainer: Performance Team

Table of Contents​

  1. Overview
  2. Performance Targets
  3. Benchmarks
  4. Bottlenecks
  5. Optimization Strategies
  6. Profiling Guide
  7. 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​

  1. Measure First - Never optimize without profiling
  2. User-Perceived Performance - Optimize for what users experience
  3. Cost-Performance Tradeoff - Balance LLM costs with quality
  4. Incremental Improvement - Small, measurable wins over big rewrites

Key Performance Indicators​

KPITargetCurrentStatus
CLI Extract Time (1000 items)< 30s18s✅
API Response Time (p95)< 500ms234ms✅
Analysis Accuracy> 0.8 confidence0.85✅
Cache Hit Rate> 70%87%✅
Adapter Fetch Time< 5s/100 items2.3s✅

Performance Targets​

Latency Targets​

By Component:

ComponentTarget (p50)Target (p95)Target (p99)
API - Extract10s25s45s
API - Analyze5s12s20s
API - Validate100ms300ms500ms
CLI - Extract15s30s60s
Adapter Fetch2s4s8s
Normalization50ms100ms200ms
LLM Analysis3s8s15s
Cache Read1ms5ms10ms
Cache Write2ms10ms20ms

Throughput Targets​

MetricTargetCurrentStatus
API Requests/sec1000450⚠️
Worker Jobs/min500320⚠️
Concurrent Extractions10045⚠️
Adapter Requests/sec50002800⚠️

Resource Utilization​

ResourceTargetAlert 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 SizeTotal TimeFetch TimeAnalysis TimeConfidence
1003.2s1.1s2.1s0.72
50012.4s4.2s8.2s0.84
100024.8s8.5s16.3s0.87
250058.3s21.2s37.1s0.89
5000112.7s42.5s70.2s0.91

Benchmark Command:

pnpm benchmark --scenario extraction --samples 1000 --iterations 10

By Platform​

Platform100 items500 items1000 items
GitHub2.1s8.4s16.7s
Twitter2.8s11.2s22.3s
Reddit3.5s14.1s28.2s
Discord2.5s10.0s20.0s

Analysis Performance​

By Provider​

ProviderModel10k chars50k chars100k charsCost
AnthropicClaude 3.5 Sonnet4.2s18.3s37.1s$0.012
OpenAIGPT-4o3.8s16.5s33.2s$0.015
Mock-< 1s< 1s< 1s$0

Chunking Performance​

Text SizeWithout ChunkingWith ChunkingSpeedup
15k chars4.2s4.2s1.0x
50k chars18.3s21.1s0.87x
100k charsTimeout42.3s2.0x+
250k charsTimeout98.2s3.0x+

Note: Chunking adds overhead but enables processing large texts.

Cache Performance​

Hit Rate by Workload​

WorkloadHit RateMiss RateAvg Latency
Repeated Queries94%6%45ms
New Queries12%88%2.1s
Mixed67%33%723ms

Cache Size vs Hit Rate​

Cache SizeHit RateMemory Used
100 keys23%12MB
1,000 keys45%120MB
10,000 keys68%1.2GB
100,000 keys87%12GB

Adapter Performance​

GitHub Adapter​

Operation100 items500 items1000 items
Fetch1.1s4.2s8.5s
Normalize45ms180ms350ms
Total1.15s4.4s8.9s

Rate Limit Behavior:

TierLimitReset TimeFull Batch Time
Unauthenticated60/hr1 hour60+ hours
Authenticated5000/hr1 hour< 1 hour

Twitter Adapter​

OperationFreeBasicPro
Rate Limit15/15min100/day300/3hr
100 items100+ min15 min5 min
1000 items1000+ min150 min50 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 BottleneckActual BottleneckResolution
LLM analysisAdapter fetchingImplemented caching
Cache I/ONetwork latencyReduced cache lookups
ProcessingGarbage collectionOptimized 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:

MonthRequests/dayPeak RPSNodes Needed
Current100K505
+1 month120K606
+3 months173K869
+6 months299K15015
+12 months891K44545

Storage Growth​

Data TypePer UserGrowth Rate12 Month Projection
Idiomark Files50KB20% MoM500GB
Cache Data100KB30% MoM2TB
Logs10MB/day10% MoM4TB

Scaling Thresholds​

Horizontal Scaling Triggers​

MetricTriggerAction
CPU> 70% sustainedAdd replicas
Memory> 75% sustainedAdd replicas or upgrade
Queue Depth> 1000Add workers
Connections> 80% maxScale database

Vertical Scaling Triggers​

MetricTriggerAction
Single Node CPU> 90%Upgrade instance type
I/O BoundHigh I/O waitMove to SSD-optimized
Memory Per RequestGrowingProfile for leaks

Cost Modeling​

LLM Cost Per Extraction​

Sample SizeAnthropicOpenAIMixed
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​

ComponentMonthly CostPer 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:

  1. Request latency heatmap
  2. Error rate by endpoint
  3. Adapter health dashboard
  4. LLM cost tracking
  5. Cache performance

Alerting​

MetricWarningCritical
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