CHAPTER 14 - Compiled Code Caching

28 views

The Zend Performance Suite’s Acceleration module, which performs com-
piled code caching, is the simplest and often the most effective way to speed up
your application. To understand what Acceleration does, we first need to go
back to the execution architecture of the Zend Engine. In the previous section,
you saw how the engine first compiles your PHP files into in-memory repre-
sentations (intermediate code), and then executes. But then what? What hap-
pens when the engine is finished executing some piece of intermediate code?
The answer is almost nothing. That is, nothing special happens with the
intermediate code; it simply becomes unallocated and destroyed. The next
time the same script will be accessed, it will be compiled again into intermedi-
ate code before it’s executed. This approach has several advantages–it fea-
tures perfect isolation across different requests, low memory footprint, and
perfect cross-platform compatibility. However, when using PHP to power a
popular web site with millions of page views a day, repetitive compilation can
become a bottleneck.
In order to boost performance, the ZPSs Acceleration module caches com-
piled intermediate code for repeated use. When installed, the ZPS replaces the
compilation procedure of the Zend Engine with a modified one; the first time
each file is accessed, the regular compiler is invoked. However, before the
resultant intermediate code is passed to the execution engine, it is saved into
shared memory for repeated later use. Once in shared memory, it is passed on
to the execution engine, which runs it as if it was in regular memory. Later,
accesses to the same file will no longer require the compilation stage, and will
move directly to the execution stage. It’s important to know that the ZPS saves
each file separately, even if it is included from another file. That means that
common include files (such as PEAR, or your own library files) are only kept in
memory once, and are used by any piece of code that needs them.
Typical benefits from using the ZPS’s acceleration module range between
a 50­300 percent performance increase. The results depend primarily on the
nature of your application. Applications with longer execution overhead (for
example, applications that spend most of their time waiting for the database
to respond) benefit less from the nullification of the compilation overhead. On
the other hand, applications that use a lot of files but have relatively short
execution overhead (for example, OO applications with one class per file) can
experience dramatic performance increase. Furthermore, the Zend Optimizer automatically detects the presence of the Zend Performance Suite, and per-
forms more aggressive and time-consuming optimizations, which would other-
wise make little sense to perform. The fact that the each file only has to be
optimized once and then used many times, combined with the additional opti-
mizations, further increases performance.
The ZPS Accelerator typically requires little configuration, if any. The
default settings fit most web sites. However, you may want to increase the
amount of available memory or the maximum number of accelerated files, for
which you can use the ZPS Console (or Settings) tab (see Figure 14.12).



« CHAPTER 14 - USING ZPS (ZEND PERFORMANCE SUITE) CHAPTER 14 - Dynamic Content Caching »
Posted on Thursday, June 7th, 2007 at 12:40 pm under PHP 5 Power Programming | RSS 2.0 Feed

Post Comment

You must be logged in to post a comment.



ComputerEducationWorld.com All Rights Reserved © RSS | CBSE | Education Boards Of India | What is My IP?