Skip to main content

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

ModuleRustPythonSpeedup
YAML to_yaml0.20s0.66s3.3x
YAML roundtrip0.29s1.62s5.6x
Text search0.048s0.099s2.1x
CSV 100K rows6.05s1.78sPyO3 FFI overhead
Graph BFS 10K0.085s0.007sPython 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
YAML and text search showed the best speedups because serde handles serialization natively without creating intermediate Python objects.

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

What’s Next

The Rust bridge pattern is now established. Future performance-critical modules can follow the same template: pure-Rust impl → PyO3 binding → Python adapter with fallback.