Skip to content

Latest commit

 

History

History
340 lines (241 loc) · 8.49 KB

File metadata and controls

340 lines (241 loc) · 8.49 KB

🚀 WSL2 Performance Fix - Stop Waiting 20+ Minutes!

🔥 IMMEDIATE ACTIONS (Stop the pain now!)

1️⃣ Cancel Current Build (If still running)

Press Ctrl+C to stop the slow compilation.

2️⃣ Use Fast Installer (Skips Rust build)

# Stop current installation (Ctrl+C)

# Run fast installer (skips slow Rust build)
sudo ./install_all_dependencies_fast.sh --skip-rust-build

This completes in ~2 minutes instead of 20+ minutes!


🎯 THE ROOT CAUSE

Your project is at: /mnt/c/Users/DaviCastroSamora/Documents/SamoraDC/RustAlgorithmTrading

This is the Windows filesystem mounted in WSL2, which causes:

  • 10-20x slower file operations
  • Rust compilation: 20+ minutes instead of 2-3 minutes
  • Every file read/write goes through Windows → Linux translation layer
  • 9P protocol overhead for cross-filesystem access

✅ PERMANENT FIX: Move to Linux Filesystem (10-20x Faster!)

Option 1: Complete Migration (Recommended)

Move your entire project to the native Linux filesystem:

# 1. Create projects directory in Linux filesystem
mkdir -p ~/projects

# 2. Copy project (this takes ~2-5 minutes one time)
cp -r /mnt/c/Users/DaviCastroSamora/Documents/SamoraDC/RustAlgorithmTrading ~/projects/

# 3. Navigate to new location
cd ~/projects/RustAlgorithmTrading

# 4. Run installation (will be FAST now - 2-3 min total)
sudo ./install_all_dependencies_fast.sh

# 5. Build Rust (NOW it's fast - 2-3 minutes!)
cd rust
cargo build --release --jobs $(nproc)

Result:

  • Total time: ~5-8 minutes (one-time migration + fast build)
  • Future builds: 2-3 minutes
  • File operations: 10-20x faster

Option 2: Symlink Strategy (Keep files on Windows)

If you need files on Windows (for backup/sharing), use symlinks:

# 1. Move project to Linux filesystem
mv /mnt/c/Users/DaviCastroSamora/Documents/SamoraDC/RustAlgorithmTrading ~/projects/

# 2. Create symlink on Windows side
ln -s ~/projects/RustAlgorithmTrading /mnt/c/Users/DaviCastroSamora/Documents/SamoraDC/RustAlgorithmTrading

# 3. Work from Linux filesystem
cd ~/projects/RustAlgorithmTrading

Result: Fast operations, but files still accessible from Windows.


⚡ QUICK SOLUTIONS (If you can't move project)

Solution 1: Skip Rust Build During Installation

# Install Python dependencies only (fast)
sudo ./install_all_dependencies_fast.sh --skip-rust-build

# Build Rust later when needed (or not at all for Python-only work)
cd rust
cargo build --release

Solution 2: Use Debug Build (2x faster than release)

# Debug builds are faster but less optimized
cd rust
cargo build --jobs $(nproc)  # No --release flag

Debug vs Release:

  • Debug: ~10-12 minutes on Windows filesystem
  • Release: 20+ minutes on Windows filesystem
  • Debug on Linux: ~1-2 minutes
  • Release on Linux: ~2-3 minutes

Solution 3: Build Incrementally

# Build one crate at a time
cd rust
cargo build -p common --jobs $(nproc)
cargo build -p market-data --jobs $(nproc)
cargo build -p execution-engine --jobs $(nproc)
cargo build -p risk-manager --jobs $(nproc)

📊 Performance Comparison

On Windows Filesystem (/mnt/c/...)

Operation Time Status
Rust Release Build 20-30 min ❌ Extremely slow
Rust Debug Build 10-12 min ⚠️ Slow
Python Install (UV) 2-3 min ✅ Fast
File Operations 10-20x slower ❌ Very slow
Git Operations 5-10x slower ⚠️ Slow

On Linux Filesystem (~/projects/...)

Operation Time Status
Rust Release Build 2-3 min ✅ Fast
Rust Debug Build 1-2 min ✅ Very fast
Python Install (UV) 1-2 min ✅ Very fast
File Operations Normal speed ✅ Fast
Git Operations Normal speed ✅ Fast

Speedup: 10-20x faster for Rust builds!


🛠️ Step-by-Step Migration Guide

Before Migration

# Check current location
pwd
# Output: /mnt/c/Users/DaviCastroSamora/Documents/SamoraDC/RustAlgorithmTrading

# Check project size
du -sh .
# Output: ~1.5 GB (with old venv)

Migration Process

# 1. Cancel any running builds
# Press Ctrl+C if installation is running

# 2. Create Linux projects directory
mkdir -p ~/projects

# 3. Copy project to Linux filesystem (takes 2-5 minutes)
echo "Copying project to Linux filesystem..."
cp -r /mnt/c/Users/DaviCastroSamora/Documents/SamoraDC/RustAlgorithmTrading ~/projects/
echo "✓ Copy complete!"

# 4. Navigate to new location
cd ~/projects/RustAlgorithmTrading

# 5. Verify location
pwd
# Output: /home/samoradc/projects/RustAlgorithmTrading

# 6. Run fast installation
sudo ./install_all_dependencies_fast.sh

# 7. Build Rust (NOW it's fast!)
cd rust
time cargo build --release --jobs $(nproc)
# Should take 2-3 minutes

# 8. Verify build
ls -lh target/release/market-data
# Should show executable

After Migration

# Your new workflow location
cd ~/projects/RustAlgorithmTrading

# Activate environment
source .venv/bin/activate

# Build Rust (fast now!)
cd rust && cargo build --release

# Start development
./scripts/start_trading.sh

🔍 Why Is WSL2 So Slow on /mnt/c/?

Technical Explanation

  1. 9P File System Protocol: WSL2 uses 9P protocol to access Windows files
  2. Translation Overhead: Every file operation translates between Linux and Windows
  3. Metadata Sync: File metadata (permissions, timestamps) synced constantly
  4. Large Dependency Trees: Rust projects have thousands of files
  5. Parallel Compilation: Cargo tries to compile in parallel, overwhelming 9P protocol

What Happens During Rust Compilation

Cargo: "Read Cargo.toml from /mnt/c/..."
↓
WSL2: "Ask Windows for file"
↓
Windows: "Here's the file (slow)"
↓
WSL2: "Translate to Linux format"
↓
[REPEAT FOR EVERY FILE - thousands of times]

On Linux filesystem:

Cargo: "Read Cargo.toml from /home/..."
↓
Linux: "Here's the file (instant)"

Result: 10-20x speed difference!


💡 Best Practices for WSL2 Development

✅ DO:

  • Store projects in ~/projects/ (Linux filesystem)
  • Use WSL2 terminal for all operations
  • Access Windows files only when needed
  • Keep heavy I/O operations on Linux filesystem

❌ DON'T:

  • Store active projects in /mnt/c/ (Windows filesystem)
  • Compile Rust/C++ projects from Windows filesystem
  • Use Windows filesystem for high I/O operations
  • Mix Linux and Windows file operations

🎯 Decision Matrix

Choose Your Solution

Need to keep working NOW? → Use sudo ./install_all_dependencies_fast.sh --skip-rust-build

Want moderate improvement (10-12 min vs 20+ min)? → Use debug build: cargo build (no --release)

Want BEST performance (2-3 min)? → Move to Linux filesystem: cp -r project ~/projects/

Have limited disk space? → Use symlink strategy (move + symlink back)

Just learning/testing? → Skip Rust build entirely, use Python components only


📚 Additional Resources

WSL2 Performance

Rust Compilation


✅ Quick Checklist

  • Stop current slow build (Ctrl+C)
  • Run fast installer: sudo ./install_all_dependencies_fast.sh --skip-rust-build
  • Decide: Move to Linux filesystem or skip Rust?
  • If moving: cp -r /mnt/c/.../project ~/projects/
  • Build Rust from new location: Fast!
  • Update bookmarks/shortcuts to new location
  • Optional: Remove old Windows copy

🎉 Expected Results

Before Fix (Windows Filesystem)

$ time cargo build --release
real    22m 34s  ❌

After Fix (Linux Filesystem)

$ time cargo build --release  
real    2m 47s   ✅

You just saved 20 minutes per build! 🚀


TL;DR: Your project is on Windows filesystem (/mnt/c/...) which is 10-20x slower for Rust compilation. Move it to Linux filesystem (~/projects/) for 2-3 minute builds instead of 20+ minutes.

Quick Fix:

sudo ./install_all_dependencies_fast.sh --skip-rust-build

Best Fix:

cp -r /mnt/c/Users/.../RustAlgorithmTrading ~/projects/
cd ~/projects/RustAlgorithmTrading
sudo ./install_all_dependencies_fast.sh