I would like to submit my extension for consideration for inclusion in PECL.


QB is an extension designed to enable PHP applications to better handle
computationally intensive tasks. While PHP is in general fast enough for
most things, in certain scenarios dynamic typing simply imposes too great
an overhead. This happens most often in image processing, where the number
of operations can easily exceed 10 million. QB alleviates this limitation
by translating and reinterpreting Zend bytecodes through a statically-typed
virtual machine, with the type information embedded in a function's Doc
Comments. It also provides the facility to compile to native code through
an external C compiler, for even greater level of performance.


QB is not a general-purpose accelerator. It's primarily designed for vector
calculation. The relationship to PHP is somewhat like OpenCL to C++: there
are restrictions on what can be done and some differences in semantics.
Multiplication involving arrays is possible in QB, for instance. Code
interpreted through the QB VM also has access to built-in functions that
don't exist in PHP (e.g. dot product).


Starting from version 2.0, QB can dispatch sections of code through
multiple CPU cores. A future goal is to make use of the GPU through OpenCL.


To illustrate the performance gain possible, I'll use a test from the
computer language shootout. On my Celeron-powered laptop, the
fannkuch-redux script (N = 500) takes 21 seconds to finish in PHP. Modified
for execution in QB, the execution time drops to 1.87 seconds. Once
compiled to native code, it drops to 0.40 second--close to what you get from
straight C.


More information about the extension can be found at http://www.php-qb.net.

Reply via email to