PHP 7 Performance PHP 7 Performance wordpress wordpress

PHP 7 Performance


According to the output of phpinfo you posted, opcache isn't enabled for your PHP 7, while it is for PHP 5. That alone can amount for a huge difference.


I currently have the same surprising results on the CLI side.

One of my old projects uses a PHING build. It was running on PHP 5.3 then PHP 5.6.I tried using PHP 7 and noticed a huge difference. So i decided to time the script execution.

FYI it is a real life projects with thousands of files processed during the build.

Build using PHP 5.3.29:3 minutes and 44 seconds elapsed.

Build using PHP 7.2.11:11 minutes and 41 seconds elapsed.

I noticed the CLI did not have opcache activated, here is the results with opcache:

Build using PHP 7.2.11 + opcache:12 minutes and 18 seconds elapsed.

Yes, WORSE

FYI:

$ php --info |grep opcacheopcache.blacklist_filename => no value => no valueopcache.consistency_checks => 0 => 0opcache.dups_fix => Off => Offopcache.enable => On => Onopcache.enable_cli => On => Onopcache.enable_file_override => Off => Offopcache.error_log => no value => no valueopcache.file_cache => no value => no valueopcache.file_cache_consistency_checks => 1 => 1opcache.file_cache_only => 0 => 0opcache.file_update_protection => 2 => 2opcache.force_restart_timeout => 180 => 180opcache.huge_code_pages => Off => Offopcache.inherited_hack => On => Onopcache.interned_strings_buffer => 8 => 8opcache.lockfile_path => /tmp => /tmpopcache.log_verbosity_level => 1 => 1opcache.max_accelerated_files => 10000 => 10000opcache.max_file_size => 0 => 0opcache.max_wasted_percentage => 5 => 5opcache.memory_consumption => 128 => 128opcache.opt_debug_level => 0 => 0opcache.optimization_level => 0x7FFFBFFF => 0x7FFFBFFFopcache.preferred_memory_model => no value => no valueopcache.protect_memory => 0 => 0opcache.restrict_api => no value => no valueopcache.revalidate_freq => 2 => 2opcache.revalidate_path => Off => Offopcache.save_comments => 1 => 1opcache.use_cwd => On => Onopcache.validate_permission => Off => Offopcache.validate_root => Off => Offopcache.validate_timestamps => On => On

Btw, I have to say I never noticed a huge difference on prod with apache when switched from PHP 5 to PHP 7. Despites all of the bechmarks we see online, the difference is far from obvious.

Neddless to say, for that project, I will stick to PHP 5 version.