12th November 2021

Making Static Site Generator 500-Times Faster

I already described some changes I made to the original Saaze software:

  1. Moved Blog To eklausmeier.goip.de
  2. Calling MD4C from PHP via FFI
  3. Considerations Regarding Simplifications of Saaze
  4. Profiling PHP Programs

In Making Static Site Generator 30-Times Faster I already described that removing unnecessary dependencies improved run-time considerably. The final dependency, which remained, was the Blade template. For this Saaze used Jens Seger's Blade implementation.

This whole template usage didn't make sense to me, when you are already programming in PHP, as PHP by itself is already an excellent template language. But as Blade was advertised to mimique PHP, I left Blade as is in the first place. I always struggled in passing variables from Saaze to Blade, so the final straw was quickly inflamed. I dropped this Blade templating, which never felt right. This again boosted performance considerably. In addition using Saaze is now way easier. You use plain PHP, which can easily be checked with

php -l template-file

You do not have to wait for the build-run of Saaze, to identify any syntax errors you made.

With all this removal of useless and obstructive stuff, which is also slowing down enormously, we can now say that we are more than 500-times faster than the original Saaze.

Added benefit: Less code to debug, less code which can have bugs.

To illustrate the risk with many unnecessary dependencies: Malware found in coa and rc, two npm packages with 23M weekly downloads. Here, only two base packages can infect a huge number of software which depend on them. Drew DeVault is paying people money, if they remove trivial npm packages, see I will pay you cash to delete your npm module.

Installation size on Arch Linux for x86 and Odroid/ARM.

Generator Size/MB x86 LoC Dependencies
S.Saaze 1.1 0.05 1221 1
Saaze 0.05 1882 16

Run times are all in seconds. "S. Saaze" is our Simplified Saaze.

Generator #posts real x86 user x86
S. Saaze 13 0.04 0.02
S. Saaze 348 0.15 0.09
S. Saaze 683 0.26 0.17
S. Saaze 1353 0.47 0.36
Saaze 13 0.10 0.08
Saaze 348 77.80 76.84
Saaze 683 156.95 155.06
Saaze 1353 321.56 318.28

Testing machine was Intel NUC, i5-4250U, max. 2.6 GHz, Arch Linux 5.14.14. The 348 are the posts of this blog. The 13 posts are the music-posts. The other test scenarios are just doubling of this data.