Rust Performance Core Accelerates Traceo MCP Server
What Happened
Traceo’s MCP server gained a Rust acceleration layer built behind stable Python interfaces. Four performance-critical modules were implemented: CSV parsing, graph algorithms (BFS/DFS/cycle detection/impact analysis), YAML serialization, and TF-IDF text search indexing.Architecture Decision
Rust modules run behind a Python adapter layer (rust_bridge) with automatic fallback to pure Python when the Rust extension is unavailable. This means:
- Zero breaking changes — existing Python code works unchanged
- Graceful degradation — if Rust build fails, Python handles the load
- Incremental adoption — each module is independent
Performance Results
| Module | Rust | Python | Speedup |
|---|---|---|---|
| YAML to_yaml | 0.20s | 0.66s | 3.3x |
| YAML roundtrip | 0.29s | 1.62s | 5.6x |
| Text search | 0.048s | 0.099s | 2.1x |
| CSV 100K rows | 6.05s | 1.78s | PyO3 FFI overhead |
| Graph BFS 10K | 0.085s | 0.007s | Python dict is fast |
Key Finding: PyO3 FFI Overhead
Building Python objects from Rust (dicts, lists) costs more than the computation itself for simple operations. The Rust advantage emerges when:- Downstream processing is bundled into a single FFI call
- The computation is complex enough to dwarf object construction
- Native data structures (serde) avoid Python object creation entirely
Business Impact
- Faster baseline syncs — YAML export/import is 3-5x faster
- Scalable traceability — graph algorithms handle 10K+ node requirement graphs
- Better search — TF-IDF queries return in under 50ms on 1000 documents
- Deploy security — deployment auth locked to single authorized principal