Similar to the earlier articles, I ran benchmarks on a Hetzner CCX11 VPS with 2 dedicated vCPU and 8 GB of RAM. I tested three scenarios using Composer 2.0.7:
- PHP 7.4
- PHP 8.0
- PHP 8.0 with JIT
I chose not to enable OPcache Preloading because of just running Composer a few times would likeny not benefit from it. The OPCache and JIT configuration(s) used:
opcache.preload_user=www-data opcache.memory_consumption=1024 opcache.interned_strings_buffer=256 opcache.max_accelerated_files=30000 opcache.validate_timestamps=0 opcache.enable=1 opcache.enable_cli=1 opcache.file_cache="/tmp/php-file-cache" opcache.file_cache_only=1 opcache.file_cache_consistency_checks=1 # only when JIT was enabled #opcache.jit_buffer_size=512mb #opcache.jit=1225
The benchmark round included the following with an Ibexa Experience installation:
- Install without a lock file and purged caches
- Require a new package (novactive/ezseobundle)
- Install with lock file, with purged caches
- Install with lock file, with filled caches
I ran this set three times with similar scripts to from before and cherry-picked the best number for each. I measured the time and memory usage for reporting.
[image: Composer install time_ PHP 7.4 & PHP 8.0 (+JIT)-min]
Regarding the duration of installation there are no great changes. With full dependency resolving is quickest with PHP 7.4 and slowest with PHP 8.0 JIT, for installation with a lock file but an empty cache non-JIT PHP 8.0 is the slowest. For cached results are identical, at just 6 seconds it's great for integrated CI/CD pipelines.
[image: Composer memory usage_ PHP 7.4 & PHP 8.0 (+JIT)-min]
For memory usage the story is even closer. PHP 8 is the most frugal with a full dependency resolve, but slightly more wasteful in the other scenarios. The differences here are quite small and thus are not very meaningful in real-world scenarios.
Based on the testing there is not much benefit for Composer when using PHP 8.0 (with or without JIT) over PHP 7.4. For more meaningful improvements I would recommend looking at upgrading from Composer 1 to Composer 2. Especially the reduced memory footprint for dependency resolving is very significant.
Feedback welcome on Discourse: Performance of Composer 2.0 with PHP 8 JIT
Photo by Javier García on Unsplash