Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Trace Comparison

Trace comparison uses renacer to verify that transpiled Rust code exhibits the same system-level behavior as the original program.

How It Works

# Trace original and transpiled programs
renacer trace --output original.trace -- python3 ./src/main.py
renacer trace --output transpiled.trace -- ./target/release/app

# Compare
renacer diff original.trace transpiled.trace

Diff Output

=== Trace Comparison Report ===
File I/O:
  MATCH: open("data/input.csv", O_RDONLY)
  MATCH: write(1, "result: 42\n", 11)
Memory:
  DIFF: allocation strategy differs (same total usage)
Exit:
  MATCH: exit_group(0)
Summary: 1 difference (non-critical)

What to Compare

AspectMethodAcceptable Differences
File writesContent exact matchNone (must be identical)
File readsPath + content hashBuffer size may differ
Exit codeExact matchNone
stdout/stderrContent matchFormatting (configurable)
MemoryTotal usageIndividual allocations differ
ThreadsOutput correctnessThread count may differ

Targeted Comparison

# Compare only file I/O
renacer diff --filter=file original.trace transpiled.trace

# Compare only network behavior
renacer diff --filter=network original.trace transpiled.trace

# Ignore expected differences
renacer diff --ignore-mmap --ignore-thread-create original.trace transpiled.trace

Pipeline Integration

The validation phase runs trace comparison automatically:

batuta validate --trace --compare ./rust_out

If differences are found, the pipeline stops (Jidoka principle) and reports the diff. Migration proceeds only when traces match or differences are explicitly accepted.


Navigate: Table of Contents