Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP performance hampered by require()

I ran my code through xdebug profiler and saw more than 30 percent of the time is spent on the require() calls. What is the best way to improve on this? I saw some posts about using __autoload, but there were conflicting statements about it's affect on APC (which we use), and doubts about it's use to improve performance.

like image 664
bob Avatar asked Feb 28 '23 13:02

bob


1 Answers

The reason why requires consume time is disk IO speed. You can try using autoloading, as you may be requiring files that aren't actually used. Another approach to reduce the disk IO overhead is to combine your PHP files into one large file. Requiring a big file which contains the code you always need is faster than including the same code in multiple small files.

Also, APC has a feature which speeds up requires called apc.include_once_override which you can try enabling.

like image 56
Jani Hartikainen Avatar answered Mar 12 '23 06:03

Jani Hartikainen