Re: QuickBinary extension for PHP
| From: | Chung Leong | Date: | Wed, 26 Feb 2014 17:52:18 +0000 |
| Subject: | Re: QuickBinary extension for PHP | ||
| References: | 1 2 | Groups: | php.pecl.dev |
| Request: | Send a blank email to pecl-dev+get-11572@lists.php.net to get a copy of this message | ||
One thing I've been wondering is whether it's possible to quickly tell
if a GD image is empty. QB code typically handles images as arrays of
float32. Conversion from GD's internal format occurs when the function
is called. Currently, QB will do all the calculations even when the
image is empty, passed in to accept the result. The calculations
themselves probably aren't that costly. Going through them does pretty
much force everything else out the L1 and L2 caches. If there's a way
to avoid taking that hit it would be nice.
On 2/26/14, Pierre Joye <pierre.php@gmail.com> wrote:
> Hi Chung,
>
> On Tue, Feb 25, 2014 at 5:35 PM, Chung Leong <cleong728@gmail.com> wrote:
>> 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.
>
> Fantastic work, this is by far the best extension I see in years, well
> done!
>
> I did not test it yet but looking quickly at the code and examples,
> looks even more great!
>
> btw, is there anything you need from a GD point of view to speed up
> things even more? or make your work or support easier? let me know :)
>
> Cheers,
> --
> Pierre
>
> @pierrejoye | http://www.libgd.org
>