-
-
Notifications
You must be signed in to change notification settings - Fork 11
Performance
Lisa edited this page Dec 18, 2025
·
13 revisions
Performance characteristics and benchmarks for CKB tools.
CKB tools are classified by performance budget:
| Budget | P95 Target | Tools |
|---|---|---|
| Cheap | < 300ms |
searchSymbols, explainFile, listEntrypoints, explainPath, getSymbol, explainSymbol
|
| Heavy | < 2000ms |
traceUsage, getArchitecture, getHotspots, summarizeDiff, recentlyRelevant, listKeyConcepts, analyzeImpact, getCallGraph, findReferences, justifySymbol
|
| Budget | P95 Target | Tools |
|---|---|---|
| Cheap | < 300ms |
getModuleResponsibilities, getOwnership, recordDecision, getDecisions, annotateModule
|
| Heavy | < 2000ms |
getArchitecture, getHotspots
|
| Heavy | < 30000ms | refreshArchitecture |
Environment: Apple M4 Pro, Go 1.23, macOS
In-memory processing functions complete in nanoseconds to microseconds:
| Function | Time | Description |
|---|---|---|
classifyFileRiskLevel |
1.0 ns | Risk classification for diff files |
classifyHotspotRisk |
0.77 ns | Churn-based risk assessment |
computeDiffConfidence |
2.2 ns | Confidence calculation |
computePathConfidence |
1.0 ns | Path confidence from basis |
detectLanguage |
7.3 ns | Language from file extension |
suggestTestPath |
19 ns | Test file path generation |
titleCase |
29 ns | Simple title casing |
classifyRecency |
43 ns | Timestamp recency classification |
computeRecencyScore |
44 ns | Recency scoring |
classifyFileRole |
78 ns | File role from path patterns |
splitCamelCase |
116 ns | CamelCase word splitting |
classifyPathRole |
297 ns | Full path role classification |
categorizeConceptV52 |
561 ns | Concept categorization |
buildDiffSummary |
674 ns | Diff summary text generation |
extractConcept |
903 ns | Concept extraction from names |
Simulated tool processing with multiple items:
| Pipeline | Items | Time | Budget | Headroom |
|---|---|---|---|---|
| PathClassification | 10 paths | 3.0 µs | 300ms | 99.999% |
| DiffProcessing | 50 files | 8.9 µs | 2000ms | 99.999% |
| HotspotProcessing | 50 items | 10.1 µs | 2000ms | 99.999% |
| ConceptExtraction | 10 names | 14.9 µs | 2000ms | 99.999% |
| Function | Time | Description |
|---|---|---|
CalculateInstability |
0.25 ns | Martin's instability metric |
ComputeCompositeScore |
0.26 ns | Weighted hotspot score |
NormalizeChurnScore |
0.25 ns | Churn normalization |
NormalizeCouplingScore |
0.25 ns | Coupling normalization |
NormalizeComplexityScore |
0.26 ns | Complexity normalization |
CalculateTrend |
295 ns | Trend analysis (30 snapshots) |
| Pipeline | Items | Time | Budget | Headroom |
|---|---|---|---|---|
| HotspotScoring | 100 files | 69 ns | 2000ms | 99.999% |
| TrendAnalysis | 50 files × 10 snapshots | 5.7 µs | 2000ms | 99.999% |
| Function | Time | Description |
|---|---|---|
normalizeAuthorKey |
10 ns | Author key normalization |
BlameOwnershipToOwners |
47 ns | Convert blame to owners |
CodeownersToOwners |
56 ns | Convert CODEOWNERS to owners |
isBot |
743 ns | Bot detection (regex) |
matchPattern |
1.9 µs | Glob pattern matching |
GetOwnersForPath |
51 µs | Resolve owners for path |
| Pipeline | Items | Time | Budget | Headroom |
|---|---|---|---|---|
| OwnershipResolution | 100 files × 50 rules | 9.2 ms | 300ms | 96.9% |
In-memory processing is negligible. Real-world latency is dominated by I/O:
- SCIP index lookups - Symbol search, references, call graph traversal
- Git history queries - Commit history, diff stats, churn metrics
- File system operations - Directory traversal, file reads
This is by design - CKB's value is in orchestrating these I/O operations efficiently and compressing results for LLM consumption.
# Run all query benchmarks
go test ./internal/query/... -bench=. -benchmem -run=^$
# Run all v6.0 benchmarks
go test ./internal/hotspots/... ./internal/ownership/... -bench=. -benchmem -run=^$
# Run specific benchmark
go test ./internal/query/... -bench=BenchmarkClassifyPathRole -benchmem -run=^$
# Run with CPU profiling
go test ./internal/query/... -bench=BenchmarkDiffProcessingPipeline -cpuprofile=cpu.prof -run=^$- Keep SCIP index fresh - Stale indexes cause fallback to slower backends
-
Use scoped queries - Adding
scopeparameter reduces search space - Set reasonable limits - Don't request 1000 results if you need 20
- Profile before optimizing - Most time is in I/O, not CPU
- Cache aggressively - CKB's three-tier cache handles this
- Batch I/O operations - Fewer round trips beats faster processing
- MCP Integration - Tool documentation and usage
- Architecture - How CKB processes queries
- Configuration - Cache and backend settings