← Back to Blog

Benchmark: Rust Compiler

Testing loct on rustc (35,387 files!)

Use Case: rust-lang/rust - The Rust Compiler

Repository: https://github.com/rust-lang/rust Stack: Rust Test Date: 2025-12-08 Loctree Version: 0.6.2-dev


Overview

The ultimate stress test for Rust analysis - analyzing THE Rust compiler source code itself.

Repository Scale

MetricValue
Rust Files35,387
Total Symbols79,891
Repository Size558 MB
Snapshot Size149 MB

Performance

MetricValue
Scan Time~45 seconds
Throughput787 files/sec
Dead Analysis< 1 second
Cycles Analysis< 1 second

Findings

Dead Code Detection

  • High Confidence: 1 finding (test fixture - intentional)
  • False Positive Rate: 0%

Circular Dependencies - Architectural Analysis

βœ“ Found 91 circular import cycles (intra-crate)

Notable cycles detected:

  1. Core Library (78-hop chain):

    core/src/alloc/layout.rs β†’ error.rs β†’ fmt/mod.rs β†’
    cell.rs β†’ cmp.rs β†’ ... (78 intermediate) ... β†’ fmt/builders.rs
    
  2. Type System (48-hop chain):

    rustc_middle/src/mir/mono.rs β†’ dep_graph/mod.rs β†’ ty/mod.rs β†’
    ... (48 intermediate) ... β†’ ty/diagnostics.rs
    
  3. AST Module:

    rustc_ast/src/ast.rs β†’ format.rs β†’ token.rs β†’
    tokenstream.rs β†’ ast_traits.rs β†’ util/parser.rs β†’ visit.rs
    

Manual Verification Result: These are NOT bugs - they are normal Rust architecture:

  • All cycles are intra-crate (crate:: imports within same library)
  • Rust allows modules within the same crate to mutually import each other
  • Compiler resolves via lazy name resolution + type checking post-resolution
  • This is fundamentally different from JavaScript/Python circular imports
  • No upstream issue warranted - this is standard Rust module organization

Twins Analysis

  • Exact Duplicates: 7,918 (mostly test main() functions)
  • False Positive Rate: 0% - expected pattern for test suite

Commands Used

cd rust-lang
loct                              # Create snapshot (45s)
loct dead --confidence high       # Dead code analysis
loct cycles                       # Circular dependencies
loct twins                        # Duplicate detection

Verdict

EXCEPTIONAL - If loctree handles rust-lang/rust, it handles ANY Rust project.

Key Insights

  1. Scalability Proven: 35K files in 45 seconds
  2. Accuracy Validated: 0% FP on dead code
  3. Cycle Detection: Found 91 real architectural cycles (intra-crate, by design)
  4. Zero Crashes: Complete analysis on 558 MB codebase

Note on Intra-Crate Cycles

Unlike JavaScript/Python where circular imports can cause undefined/None at runtime, Rust's module system handles intra-crate cycles gracefully:

// This is VALID Rust - fmt imports cell, cell imports fmt
// crate::fmt::mod.rs
use crate::cell::Cell;

// crate::cell.rs
use crate::fmt::{Debug, Display};

Loctree correctly detects these architectural patterns but they should be interpreted as "module interdependencies" rather than "problematic cycles."


πš…πš’πš‹πšŽπšŒπš›πšŠπšπšπšŽπš. with AI Agents by VetCoders (c)2024-2026 LibraxisAI