Pragmatic PHP |
|
2024-11-25 |
|
|
25 |
|
|
So, we have determined we are cpu-bound and we need to go faster. What can we do?
Some low-hanging fruit:
include_path
include_path = "/usr/share/pear:."
<?php
include './template_helpers.inc';
include 'business_logic.inc';
?>
open_basedir
open_basedir = "/usr/share/htdocs/:/usr/share/pear/"
open_basedir checking adds some extra syscalls to every file operation. It can be useful,
but it is rather expensive, so turn it off if you don't think you need it.
variables_order
<?php
echo $_SERVER['DOCUMENT_ROOT'];
echo getenv('DOCUMENT_ROOT');
?>
If you never use cookies, turn those off too
Output buffering?
Add an Opcode Cache
extension=apc.so
apc.shm_segments=1
apc.shm_size=64
apc.num_files_hint=1000
apc.mmap_file_mask=/tmp/apc.XXXXXX
Switch to semaphore locking in APC
CPPFLAGS=-I/usr/include/apache-1.3 \
./configure' --enable-apc --enable-mmap --enable-sem
Apply some of the hacks floating around
- • http://lerdorf.com/php/syscall.txt
- • http://lerdorf.com/php/non-pic.txt