Skip to content

Performance

Lisa edited this page Dec 17, 2025 · 13 revisions

CKB Performance

Performance characteristics and benchmarks for CKB navigation tools.

Latency Targets

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

Benchmark Results

Environment: Apple M4 Pro, Go 1.23, macOS

Helper Function Performance

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

Pipeline Performance

Simulated tool processing with multiple items:

Pipeline Items Time Budget Headroom
PathClassification 10 paths 3.0 us 300ms 99.999%
DiffProcessing 50 files 8.9 us 2000ms 99.999%
HotspotProcessing 50 items 10.1 us 2000ms 99.999%
ConceptExtraction 10 names 14.9 us 2000ms 99.999%

Where Time Actually Goes

In-memory processing is negligible. Real-world latency is dominated by I/O:

  1. SCIP index lookups - Symbol search, references, call graph traversal
  2. Git history queries - Commit history, diff stats, churn metrics
  3. 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.

Running Benchmarks

# Run all benchmarks
go test ./internal/query/... -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=^$

Optimization Tips

For Users

  1. Keep SCIP index fresh - Stale indexes cause fallback to slower backends
  2. Use scoped queries - Adding scope parameter reduces search space
  3. Set reasonable limits - Don't request 1000 results if you need 20

For Contributors

  1. Profile before optimizing - Most time is in I/O, not CPU
  2. Cache aggressively - CKB's three-tier cache handles this
  3. Batch I/O operations - Fewer round trips beats faster processing

Related

Clone this wiki locally