One more opcache for php (Preview) 30
I'm sure you use lighttpd because of performance and scalability, and many of you run php too. I'm please to introduce you another opcode cache for php.
Yes, another.
The preview version is deprecated. please check http://trac.lighttpd.net/xcache/wiki/GettingSource to get newer source.
and report problems at http://trac.lighttpd.net/xcache/newticket
Introducing
I myself, have used apc, mmcache/ea, ZendOptimizer, The only 3 choices before xcache. ab cache is too old and dead, saidly, before i use it. Every one of u write php script know them, and have one if them boost your php performance, because they're good.
But "What? Why you just introduce another opcode cacher?" It take some time to explain ... the short term: it give you one more choice. the long term: mmcache/ea is the most optimized php-opcache. ZendOptimizer isn't pre-built on all platform -- they release binary not source file. apc was stable on php4 but not works with php5, and now, is said works with php5 but php4 is left to desert...
Highlight spot of xcache
- cacher, similar as other opcaches.
- opcode disassembler, to see how your scripts looks after they're compiled into opcode.
- grows as php grows, using automated discover scheme by the devel, and the new changes to xcache to catch up new php version is brought to you easily.
- php4.x lastest is stably supported, php5.x lastest just works, php6-devel is supported for your further vision.
- many more ...
New function for script
$ grep proto *.c
mixed xcache_get(string name)
bool xcache_set(string name, mixed value [, int ttl])
mixed xcache_isset(string name)
bool xcache_unset(string name)
int xcache_inc(string name [, int value [, int ttl]])
int xcache_dec(string name [, int value [, int ttl]])
other proto need documented.
How to install
$ wget http://blog.lighttpd.net/files/xcache-preview.tar.gz
$ tar -zxf xcache-preview.tar.gz
$ cd xcache-preview
$ phpize
$ cat ./conf
$ ./configure --help
$ ./configure --enable-xcache-disassembler
$ make
$ su
# make install
take care about the output of make install append the following to php.ini:
[xcache]
xcache.size = 64M
xcache.mmap_path = "/tmp/xcache"
xcache.cacher = 1
zend_extension="/usr/.../extensions/..../xcache.so"
# or
extension="xcache.so"
Testing
restart your php (fastcgi or mod_php), check output for xcache status. if you see it there, you're done.
and finally test the opcode dumper:
$ ./phpdop.phpr ./phpdop.phpr
$ ./phpdc.phpr ./phpdc.phpr
Patch for hardened source (not tested)
Index: processor.m4
===================================================================
--- processor.m4 (revision 27)
+++ processor.m4 (working copy)
@@ -575,6 +575,9 @@
/* reserved */
DONE(reserved)
+ #if defined(HARDENING_PATCH) && HARDENING_PATCH
+ DISPATCH(zend_bool, created_by_eval)
+ #endif
} while (0);
')
dnl }}}
it is suggested to modify processor/processor.m4 directly as there might be spaces lost in blog.
Trackbacks
Use the following link to trackback from your own site:
http://blog.lighttpd.net/articles/trackback/170
$ phpize $ ./conf $ make (...snip...) ==== calc zend_op_array ================= expected: type function_name scope fn_flags prototype num_args required_num_args arg_info pass_rest_by_reference return_reference refcount opcodes last size vars last_var size_var T brk_cont_array last_brk_cont current_brk_cont try_catch_array last_try_catch static_variables start_op backpatch_count done_pass_two uses_this filename line_start line_end doc_comment doc_comment_len reserved created_by_eval missing : created_by_eval ==== store HashTable ================= ==== store zval ================= ==== store zend_op_array ================= ==== restore HashTable ================= ==== restore zval ================= ==== dprint HashTable ================= ==== dprint zval ================= ==== dprint zend_op_array ================= ==== dasm HashTable ================= ==== dasm zval ================= ==== dasm zend_op_array ================= ==== asm HashTable ================= ==== asm zval ================= ==== asm zend_op_array ================= make: *** [processor.out] Error 1System info: Slackware 10.0.0, GCC 3.3.4, PHP 5.1.2