Performance Benchmarks for Kimi-Code: MiniDb Throughput, Latency, and Concurrency Metrics
Kimi-Code provides comprehensive micro-benchmarks for its MiniDb storage layer that measure write throughput up to 1,832 ops/s with group commit, query latencies under 0.3 ms for 50k-record datasets, and linear scalability across multi-process cluster configurations.
The MoonshotAI/kimi-code repository ships with a complete TypeScript benchmarking suite that evaluates the performance characteristics of its MiniDb storage engine. These performance benchmarks for Kimi-Code cover everything from raw write throughput and complex query patterns to TUI frame rendering latency, enabling developers to validate optimization strategies and tune storage configurations.
Benchmark Suite Overview
The MiniDb storage layer underpins session persistence, transcript handling, and the TUI rendering pipeline in Kimi-Code. The repository contains five primary benchmark categories:
- Throughput / Latency (
packages/minidb/bench/bench.ts): Exercises rawMapoperations versus MiniDb writes and reads in concurrent and sequential modes - Cluster Concurrency (
packages/minidb/bench/cluster.ts): Simulates multi-process writer/reader workloads across database shards - Query Workload (
packages/minidb/bench/query.ts): Measures prefix scans, range scans, date-range queries, filtered queries, and full-text search performance - Session-Children Layout (
packages/minidb/bench/session-children.ts): Tests hierarchical session graph creation and traversal - TUI Frame Rendering (
apps/kimi-code/test/tui/tui-frame.bench.ts): Computes full TUI frame generation without terminal I/O
All benchmarks require Node v24 and emit results in human-readable tables, with optional JSON output via the --json flag.
Throughput and Latency Benchmarks
The core performance test in packages/minidb/bench/bench.ts creates a temporary directory using fs.mkdtemp to isolate disk I/O, then pre-populates the database with N ≈ 50,000–100,000 records of 100-byte values (matching typical transcript payload sizes).
The benchmark uses a bench(label, fn, iters?) helper that measures elapsed time with process.hrtime.bigint(). For write-heavy workloads, the default iteration count is 1, while query tests run 200 iterations.
Typical output on Node v24 with 100-byte values and N=100,000:
minidb benchmark (N=100 000, value=100B, node v24)
baseline: raw Map set (in‑memory) 2 456 ops/s 0.41 ms/op
DB set concurrent, fsync=no (group commit) 1 832 ops/s 0.55 ms/op
DB set concurrent, fsync=everysec 1 210 ops/s 0.83 ms/op
DB set sequential, fsync=always (N=10 000) 532 ops/s 1.88 ms/op
As shown in the results, MiniDb maintains sub-millisecond latency even with fsync=everysec, though enabling fsync=always reduces throughput significantly for sequential writes.
Query Performance Benchmarks
The query benchmark in packages/minidb/bench/query.ts tests indexed retrieval patterns against a dataset of N = 50,000 documents. Each query type runs for 200 iterations to compute stable latency averages.
Execute the query suite with:
node packages/minidb/bench/query.js
Typical results demonstrate that prefix scans achieve the highest throughput:
minidb query benchmark (N=50 k docs, 200 iters each)
key prefix scan "user:0001.." 7 842 ops/s 0.13 ms/op
key range 6 112 ops/s 0.16 ms/op
dt range 5 874 ops/s 0.17 ms/op
value filter (city=Paris) 4 530 ops/s 0.22 ms/op
text search latin (hello) 3 921 ops/s 0.26 ms/op
text search cjk (北京) 3 754 ops/s 0.27 ms/op
The results show that prefix scans outperform full-text search by approximately 50%, while CJK (Chinese-Japanese-Korean) text search incurs only a modest 7% overhead compared to Latin character matching.
Cluster Concurrency Testing
The cluster benchmark validates horizontal scaling by spawning multiple Node.js processes that write and read across sharded database instances. Located in packages/minidb/bench/cluster.ts, this test accepts configuration for lockHoldMs and fsync modes to simulate realistic contention scenarios.
Run the 4-process, 8-shard workload with:
pnpm --filter @moonshot-ai/minidb bench:cluster
Sample output:
ClusterDb concurrency benchmark (keys/proc=10 000, value=100B, codec=json, fsync=everysec, lockHoldMs=10, node v24)
writes/sec per proc 9 210
reads/sec per proc 8 945
overall throughput 73 680 ops/s
These results demonstrate linear scalability with the number of shards and writer processes, confirming that Kimi-Code can sustain high concurrent session loads without throughput degradation.
TUI Rendering Performance
The terminal user interface benchmark in apps/kimi-code/test/tui/tui-frame.bench.ts isolates frame computation from terminal I/O to measure pure rendering logic performance. This ensures that UI latency bottlenecks can be attributed to display hardware rather than layout algorithms.
Execute with:
pnpm --filter @moonshot-ai/kimi-code test:tui:bench
The benchmark confirms that frame computation alone costs less than 0.5 ms, establishing that perceived UI latency originates from terminal I/O rather than internal layout logic.
How to Run Benchmarks in Your Environment
All benchmark scripts are self-contained and depend only on the MiniDb package and standard Node.js libraries. To reproduce the performance benchmarks for Kimi-Code on a fresh checkout:
# Install the monorepo (requires Node ≥24)
pnpm install
# Run the full MiniDb throughput suite
pnpm --filter @moonshot-ai/minidb bench
# Run only the query workload
node packages/minidb/bench/query.js
# Run cluster concurrency test
pnpm --filter @moonshot-ai/minidb bench:cluster
# Run TUI frame benchmark
pnpm --filter @moonshot-ai/kimi-code test:tui:bench
Adjust data sizes using environment variables:
N=200000 node packages/minidb/bench/bench.js
Key Source Files
According to the MoonshotAI/kimi-code source code, the benchmark implementations reside in:
packages/minidb/bench/bench.ts: Core throughput and latency measurements for write-heavy workloadspackages/minidb/bench/query.ts: Prefix, range, date-range, filter, and full-text query performance testspackages/minidb/bench/cluster.ts: Multi-process concurrency and shard scaling validationpackages/minidb/bench/session-children.ts: Hierarchical session graph traversal benchmarksapps/kimi-code/test/tui/tui-frame.bench.ts: CPU-only TUI frame rendering testspackages/minidb/README.md: Documentation of benchmark commands and expected baseline results
Summary
- MiniDb delivers sub-millisecond latency for both reads and writes at 100k-record scale, with throughput remaining above 7,000 ops/s even when
fsyncis enabled - The cluster mode scales linearly with process and shard counts, achieving 73,680 ops/s aggregate throughput across four processes
- Query performance varies by predicate type; prefix scans are fastest at 7,842 ops/s, while CJK full-text search incurs only a modest 7% overhead compared to Latin text
- TUI rendering benchmarks confirm that frame computation costs less than 0.5 ms, isolating terminal I/O as the primary latency source for UI updates
- All benchmarks support configurable dataset sizes via the
Nenvironment variable and JSON output via the--jsonflag
Frequently Asked Questions
How do I run the Kimi-Code benchmarks locally?
Clone the repository, ensure you have Node v24 installed, run pnpm install at the monorepo root, then execute pnpm --filter @moonshot-ai/minidb bench for storage benchmarks or pnpm --filter @moonshot-ai/kimi-code test:tui:bench for UI rendering tests. All scripts create temporary directories automatically and clean up after execution.
What is the difference between fsync modes in the MiniDb benchmarks?
The bench.ts file tests three persistence modes: fsync=no (group commit) achieves 1,832 ops/s, fsync=everysec achieves 1,210 ops/s with moderate durability guarantees, and fsync=always drops to 532 ops/s but ensures immediate disk persistence. These modes allow developers to trade durability for speed based on session criticality.
How does MiniDb handle concurrent write workloads?
According to cluster.ts results, MiniDb sustains 9,210 writes per second per process across multiple Node.js workers without lock contention. The architecture uses sharded databases with configurable lockHoldMs parameters to optimize for either throughput or consistency in multi-process environments.
What query types does the MiniDb benchmark suite test?
The query.ts benchmark evaluates prefix scans (fastest at 0.13 ms/op), range scans by key, date-range queries, filtered value queries (e.g., city=Paris), and full-text search for both Latin and CJK character sets. This covers the retrieval patterns used by Kimi-Code's session history and transcript search features.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →