Conversation
Move all ReflectionClass/ReflectionMethod instantiation from per-call to constructor-time. Eliminates ~8 reflection objects per compilation pass.
Memoize the file read so repeated content() calls on the same instance don't hit the filesystem.
Avoid repeated realpath() syscalls for the same file and path arguments in isEnabled().
Benchmark Result: Default
Median of 10 attempts, 5000 iterations x 10 rounds, 45.89s total To run a specific benchmark, comment |
6071e8c to
38c6d46
Compare
|
Aren't we going to blow up the memory by caching contents of every single component? The |
content() is only called once per component during normal compilation (in the constructor). The cache never gets a second hit and just holds file contents in memory unnecessarily.
Although I think the memory usage will be quite little for 99% of the apps, perhaps it can grow bigger for very large apps using Octane. I've removed the |
Caches objects and results that were being recreated on every compilation pass:
ReflectionClass/ReflectionMethodinstantiations from per-call to constructorpreg_replacecalls withstr_containschecks. Most templates don't contain{{--,@verbatim, or@phpfile_get_contentsso repeatedcontent()calls don't re-read the filerealpath()results to avoid repeated syscalls for the same pathsAlso adds a
compilationbenchmark (/benchmark compilation) that measuresBlazeManager::compile()throughput directly.Locally these changes make about a 24-42% compilation speedup compared to main
Note: For the best CI comparison, cherry-pick the benchmark commit (
38c6d46) onto main first so the snapshot step can generate a baseline.