Generating OG images on every build was killing my Astro build times.
astro-takumi was re-rasterizing every page on every run, even when the HTML hadn't changed.
I forked the repo (elcoosp/astro-takumi) to fix it. What worked:
- Content-hash cache: Hash the input HTML and config, then fs.copyFile on a hit. Drops warm builds (80 pages) to ~6ms.
- Load fonts once: Registered font buffers once in the Rust core instead of re-parsing them per page.
- Bounded concurrency: Replaced unbounded Promise.all with a worker queue to prevent memory spikes.
- Lazy DOM: Skip jsdom/linkedom completely if the render function doesn't reference document.
What failed (and got reverted):
- Swapping native crypto SHA-256 for pure-JS MurmurHash3. Native hardware-accelerated SHA-256 was faster in benchmarks (1.15ms vs 1.16ms for 1,000 inputs).
- String slice "GC hints" to help V8, which immediately threw a TypeError because JS strings are immutable.
The PR is still open against upstream (vikas5914/astro-takumi). Patched fork is here: https://github.com/elcoosp/astro-takumicommit cb116b2