Re: QuickBinary extension for PHP
| From: | Christopher Jones | Date: | Tue, 25 Feb 2014 19:08:49 +0000 |
| Subject: | Re: QuickBinary extension for PHP | ||
| References: | 1 | Groups: | php.pecl.dev |
| Request: | Send a blank email to pecl-dev+get-11570@lists.php.net to get a copy of this message | ||
On 02/25/2014 08:35 AM, Chung Leong 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.On older-but-still-common Linuxes, there are some build issues. If you decide not to support these platforms, is there anyway you can fail earlier during configuration and give a good error message? On more recent versions there are some warnings but the tests run fine. Chris ------------------------------------------------------------------------------- On Oracle Linux 6.4 64-bit (identical to RHEL 6.4) with PHP 5.5.9 using gcc version 4.4.7 20120313 (Red Hat 4.4.7-3) (GCC): 1. buildconf warning
$ ./buildconf --force
Forcing buildconf
Removing configure caches
buildconf: checking installation...
buildconf: autoconf version 2.63 (ok)
rebuilding configure
ext/qb/config.m4:43: warning: AC_COMPILE_IFELSE was called before AC_USE_SYSTEM_EXTENSIONS
../../lib/autoconf/specific.m4:386: AC_USE_SYSTEM_EXTENSIONS is expanded from...
ext/qb/config.m4:43: warning: AC_RUN_IFELSE was called before AC_USE_SYSTEM_EXTENSIONS
rebuilding main/php_config.h.in
ext/qb/config.m4:43: warning: AC_COMPILE_IFELSE was called before AC_USE_SYSTEM_EXTENSIONS
../../lib/autoconf/specific.m4:386: AC_USE_SYSTEM_EXTENSIONS is expanded from...
ext/qb/config.m4:43: warning: AC_RUN_IFELSE was called before AC_USE_SYSTEM_EXTENSIONS
2. Help text alignment
The help message in "./configure --help" is not aligned with other
extensions' messages:
...
--disable-posix Disable POSIX-like functions
--with-pspell=DIR Include PSPELL support.
GNU Aspell version 0.50.0 or higher required
--enable-qb Enable qb support
--with-sse=VER Enable SSE optimization. VER is the SSE version
--with-avx=VER Enable AVX optimization. VER is the AVX version
--with-cpu=arch Enable optimization specific to CPU archecture
...
3. Compile warning
/home/cjones/j/php-5.5.9/ext/qb/qb_encoder.c: In function ‘qb_encode_address’:
/home/cjones/j/php-5.5.9/ext/qb/qb_encoder.c:87: warning: passing argument 3 of ‘qb_get_pointer’ from incompatible pointer type
/home/cjones/j/php-5.5.9/ext/qb/qb_encoder.c:53: note: expected ‘void **’ but argument is of type ‘uint32_t **’
/home/cjones/j/php-5.5.9/ext/qb/qb_encoder.c:98: warning: passing argument 3 of ‘qb_get_pointer’ from incompatible pointer type
/home/cjones/j/php-5.5.9/ext/qb/qb_encoder.c:53: note: expected ‘void **’ but argument is of type ‘uint32_t **’
/home/cjones/j/php-5.5.9/ext/qb/qb_encoder.c:99: warning: passing argument 3 of ‘qb_get_pointer’ from incompatible pointer type
/home/cjones/j/php-5.5.9/ext/qb/qb_encoder.c:53: note: expected ‘void **’ but argument is of type ‘uint32_t **’
4. Test Results:
Number of tests : 493 394
Tests skipped : 99 ( 20.1%) --------
Tests warned : 0 ( 0.0%) ( 0.0%)
Tests failed : 0 ( 0.0%) ( 0.0%)
Expected fail : 0 ( 0.0%) ( 0.0%)
Tests passed : 394 ( 79.9%) (100.0%)
---------------------------------------------------------------------
Time taken : 41 seconds
-------------------------------------------------------------------------------
On Oracle Linux 5.10 64-bit (identical to RHEL 5.10) with PHP 5.5.9 using
gcc version 4.1.2 20080704 (Red Hat 4.1.2-54):
1. buildconf error
$ ./buildconf --force
Forcing buildconf
Removing configure caches
buildconf: checking installation...
buildconf: autoconf version 2.59 (ok)
rebuilding configure
configure:101040: error: possibly undefined macro: AC_USE_SYSTEM_EXTENSIONS
If this token and others are legitimate, please use m4_pattern_allow.
See the Autoconf documentation.
rebuilding main/php_config.h.in
When later running './configure --enable-qb' there is the message:
checking whether to enable qb support... yes
checking whether to use SSE instructions on x86 processors... no
checking whether to use AVX instructions on x86 processors... no
checking whether to enable CPU-specific optimization... no
checking for library containing exp... none required
./configure: line 101040: AC_USE_SYSTEM_EXTENSIONS: command not found
2. Compile warnings
3a. /tmp/php-5.5.9/ext/qb/qb_function_inliner.h:52:7: warning: no newline at end of file
3b. /tmp/php-5.5.9/ext/qb/qb_printer.h:40:7: warning: no newline at end of file
3c. In file included from /tmp/php-5.5.9/ext/qb/qb.h:142,
from /tmp/php-5.5.9/ext/qb/qb_encoder.c:21:
/tmp/php-5.5.9/ext/qb/qb_encoder.c: In function ‘qb_encode_address’:
/tmp/php-5.5.9/ext/qb/qb_encoder.c:87: warning: passing argument 3 of ‘qb_get_pointer’ from incompatible pointer type
/tmp/php-5.5.9/ext/qb/qb_encoder.c:98: warning: passing argument 3 of ‘qb_get_pointer’ from incompatible pointer type
/tmp/php-5.5.9/ext/qb/qb_encoder.c:99: warning: passing argument 3 of ‘qb_get_pointer’ from incompatible pointer type
3. Compile error
In file included from /tmp/php-5.5.9/ext/qb/qb.h:142,
from /tmp/php-5.5.9/ext/qb/qb_interpreter_functions_gcc.c:21:
/tmp/php-5.5.9/ext/qb/qb_interpreter_functions_gcc.c:33374: error: ‘qsort_r’ undeclared here (not in a function)
make: *** [ext/qb/qb_interpreter_functions_gcc.lo] Error 1
-------------------------------------------------------------------------------
--
christopher.jones@oracle.com http://twitter.com/ghrd
Free PHP & Oracle book:
http://www.oracle.com/technetwork/topics/php/underground-php-oracle-manual-098250.html