PHP opcode caches – require_once is slow

, , , ,

If you got a large OO PHP application, you usually come with many files included using “require_once()”. Different test from different sources shows that using require_once works up to 4 times slower than require. Basically, all known PHP opcode caches suffers from this issue (APC, XCache, ea/mmcache).

There’s patches committed in APC that focus on this problem. They override INCLUDE_ONCE/REQUIRE_ONCE opcode handling whenever possible, although a bit ugly. This isn’t done in XCache yet. Ugly because isn’t not that php-src support caches, but caches support php-src.

Solution: general advice here is replacing all “require_once()” calls with “require()”, it should speed up the application.

Read about alternative PHP opcode cache (APC) and __autoload() performance 

{ttags=php opcode+cache apc xcache eaccelerator mmcache issues require_once}

This website uses IntenseDebate comments, but they are not currently loaded because either your browser doesn't support JavaScript, or they didn't load fast enough.

Leave a Comment