From 0 to 0.4s Builds: Optimizing File IO in C
How we used dirent, stat cache, and buffered writes to make CAX SSG blazing fast.
IO is The Bottleneck
Template rendering is fast. File IO kills you.
Optimizations
- Single `opendir` pass - collect + render in one loop
- Minify CSS in-place - no external tool
- Write only if changed - compare mtime
Result:
content/ (2 posts)
templates/ (4 layouts)
_data/ (2 json)
Build time: 0.04s
For 1000 posts: ~0.4s.
Pure C fread + fwrite beats Node fs any day.