This release introduces a major architectural refactoring, replacing the tokio
asynchronous runtime with a CPU-bound parallelism model powered by rayon
. This change simplifies the entire concurrency model, improves robustness, and makes the application significantly more efficient for its core analysis tasks.
🚀 Performance & Memory Improvements
The new rayon
-based pipeline has resulted in significant optimizations. Benchmarks comparing this release with the previous version show substantial speedups on small-to-medium projects and dramatic memory reductions on large codebases.
PSL Project (Small-to-Medium Codebase)
Command | Metric | Before | After | Improvement |
---|---|---|---|---|
mago analyze
| Speed | 152.0 ms | 110.2 ms | +38% Faster |
Memory (RSS) | 156.52 MB | 127.69 MB | -18.4% Memory | |
Memory (Peak) | 146.49 MB | 117.16 MB | -20.0% Memory | |
mago format
| Speed | 32.7 ms | 30.1 ms | +8.6% Faster |
Memory (RSS) | 44.05 MB | 38.39 MB | -12.8% Memory | |
Memory (Peak) | 40.85 MB | 35.00 MB | -14.3% Memory | |
mago lint
| Speed | 106.8 ms | 86.8 ms | +23.0% Faster |
Memory (RSS) | 126.31 MB | 126.69 MB | ~ Neutral | |
Memory (Peak) | 118.63 MB | 119.78 MB | ~ Neutral | |
mago lint -c
| Speed | 87.0 ms | 86.3 ms | ~ Neutral |
Memory (RSS) | 122.77 MB | 124.67 MB | ~ Neutral | |
Memory (Peak) | 115.91 MB | 117.60 MB | ~ Neutral | |
mago lint -s
| Speed | 25.5 ms | 24.5 ms | +4.1% Faster |
Memory (RSS) | 34.86 MB | 29.11 MB | -16.5% Memory | |
Memory (Peak) | 31.57 MB | 25.64 MB | -18.8% Memory |
WordPress Project (Large Codebase)
Command | Metric | Before | After | Improvement |
---|---|---|---|---|
mago analyze
| Speed | 6.511 s | 6.489 s | ~ Neutral |
Memory (RSS) | 1709.19 MB | 1375.25 MB | -19.5% Memory | |
Memory (Peak) | 1503.40 MB | 1168.82 MB | -22.2% Memory | |
mago format
| Speed | 2.049 s | 2.068 s | ~ Neutral |
Memory (RSS) | 306.52 MB | 293.14 MB | -4.4% Memory | |
Memory (Peak) | 218.21 MB | 219.52 MB | ~ Neutral | |
mago lint -s
| Speed | 322.6 ms | 324.9 ms | ~ Neutral |
Memory (RSS) | 208.25 MB | 192.06 MB | -7.8% Memory | |
Memory (Peak) | 200.22 MB | 186.08 MB | -7.1% Memory |
🛠️ Architectural Overhaul: Tokio to Rayon
The most significant change in this version is the complete removal of the tokio
runtime. While tokio
is excellent for I/O-bound tasks, Mago's workload (parsing, type inference, linting) is fundamentally CPU-bound. The switch to rayon
's data-parallel model is better suited for this and has several key benefits:
- Simplified Concurrency: The complex
async
/await
logic and manual task management have been replaced with a cleaner, more direct parallel iterator pattern. All commandexecute
functions are now synchronous. - New
pipeline
Abstraction: The core logic for theanalyze
,lint
, andformat
commands has been extracted into a new, reusablepipeline
module. This provides two distinct orchestrators for different needs:ParallelPipeline
for complex, multi-phase tasks that require a globalCodebaseMetadata
.StatelessParallelPipeline
for simple, single-phase tasks like formatting.
🐛 Fixes & Improvements
- Directory Exclusions: Fixed a bug where directory exclusions were not applied correctly. The previous logic performed an exact path match, which failed for files within an excluded directory. The check now correctly uses
starts_with
to exclude all nested paths. - Path Handling: All user-provided paths (for sources, includes, and excludes) are now canonicalized upfront to ensure consistent and correct behavior.
- File Size Limit: Added a safeguard to prevent the loader from attempting to read files larger than 1GB, providing a clear error instead of a potential crash.
Full Changelog: 1.0.0-alpha.6...1.0.0-alpha.7