php8 jit msgpack.php benchmarks
<?php | |
// see https://gist.github.com/rybakit/8f1cf53e4a673443d84e | |
namespace Bench; | |
use App\MessagePack\PackedMap; | |
use App\MessagePack\PackedMapTransformer; | |
use MessagePack\BufferUnpacker; | |
use MessagePack\Packer; | |
use MessagePack\PackOptions; | |
require __DIR__.'/../vendor/autoload.php'; | |
const ITERATIONS = 1000; | |
$packer = new Packer(PackOptions::FORCE_STR); | |
$unpacker = new BufferUnpacker(); | |
$item = [ | |
'str' => 'bar', | |
'array' => array_fill(0, 100, 42), | |
'map' => ['a' => 'a', 'b' => 'b', 'c' => 'c', 'd' => 'd', 'e' => 'e'], | |
'bool' => false, | |
'int' => 65535, | |
'float' => 65535.42, | |
]; | |
$data = []; | |
for ($i = 100; $i; --$i) { | |
$data[] = $item; | |
} | |
$time = microtime(true); | |
for ($i = ITERATIONS; $i; --$i) { | |
$packed = $packer->pack($data); | |
$raw = $unpacker->reset($packed)->unpack(); | |
} | |
printf("pure msgpack: %.4f sec, %d bytes\n", microtime(true) - $time, strlen($packed)); | |
require __DIR__.'/../examples/MessagePack/PackedMap.php'; | |
require __DIR__.'/../examples/MessagePack/PackedMapTransformer.php'; | |
$transformer = new PackedMapTransformer(3); | |
$schema = [ | |
'str' => 'str', | |
'array' => 'array', | |
'map' => 'map', | |
'bool' => 'bool', | |
'int' => 'int', | |
'float' => 'float', | |
]; | |
$packer->registerTransformer($transformer); | |
$unpacker->registerTransformer($transformer); | |
$time = microtime(true); | |
for ($i = ITERATIONS; $i; --$i) { | |
$packed = $packer->pack(new PackedMap($data, $schema)); | |
$raw = $unpacker->reset($packed)->unpack(); | |
} | |
printf("pure msgpack packed: %.4f sec, %d bytes\n", microtime(true) - $time, strlen($packed)); |
$ git clone https://github.com/zendtech/php-src.git | |
$ cd php-scr | |
$ ./buildconf --force | |
$ ./configure --disable-cgi --disable-libxml --disable-dom --disable-simplexml --disable-xml --disable-xmlreader --disable-xmlwriter --disable-pdo --without-sqlite3 --without-pear --enable-opcache | |
$ make -j "$(nproc)" | |
$ git branch | |
* jit-dynasm | |
$ git log -n 1 | |
commit 4d2bd073d23fc6549a31d37bf6c74c97e91e76b4 | |
$ git clone https://github.com/rybakit/msgpack.php.git | |
$ (cd msgpack.php && composer install) | |
$ (cd msgpack.php && git log -n 1) | |
commit b03902f011e605b60a7b1c03a822ac54e30858a3 | |
$ sapi/cli/php -v | |
PHP 8.0.0-dev (cli) (built: Feb 7 2019 09:06:02) ( NTS ) | |
Copyright (c) 1997-2018 The PHP Group | |
Zend Engine v4.0.0-dev, Copyright (c) Zend Technologies | |
$ sapi/cli/php -dextension_dir=`pwd`/modules -dzend_extension=opcache.so -v | |
PHP 8.0.0-dev (cli) (built: Feb 7 2019 09:06:02) ( NTS ) | |
Copyright (c) 1997-2018 The PHP Group | |
Zend Engine v4.0.0-dev, Copyright (c) Zend Technologies | |
with Zend OPcache v8.0.0-dev, Copyright (c) 1999-2019, by Zend Technologies | |
$ sapi/cli/php -dextension_dir=`pwd`/modules -dzend_extension=opcache.so -dpcre.jit=1 -dopcache.enable_cli=1 -dopcache.jit=1235 -dopcache.file_update_protection=0 -dopcache.jit_buffer_size=256M --ri 'Zend OPcache' | |
Zend OPcache | |
Opcode Caching => Up and Running | |
Optimization => Enabled | |
SHM Cache => Enabled | |
File Cache => Disabled | |
Startup => OK | |
Shared memory model => mmap | |
Cache hits => 0 | |
Cache misses => 0 | |
Used memory => 9167704 | |
Free memory => 125050024 | |
Wasted memory => 0 | |
Interned Strings Used memory => 137080 | |
Interned Strings Free memory => 6153928 | |
Cached scripts => 0 | |
Cached keys => 0 | |
Max keys => 16229 | |
OOM restarts => 0 | |
Hash keys restarts => 0 | |
Manual restarts => 0 | |
Directive => Local Value => Master Value | |
opcache.enable => On => On | |
opcache.use_cwd => On => On | |
opcache.validate_timestamps => On => On | |
opcache.validate_permission => Off => Off | |
opcache.validate_root => Off => Off | |
opcache.dups_fix => Off => Off | |
opcache.revalidate_path => Off => Off | |
opcache.log_verbosity_level => 1 => 1 | |
opcache.memory_consumption => 128 => 128 | |
opcache.interned_strings_buffer => 8 => 8 | |
opcache.max_accelerated_files => 10000 => 10000 | |
opcache.max_wasted_percentage => 5 => 5 | |
opcache.consistency_checks => 0 => 0 | |
opcache.force_restart_timeout => 180 => 180 | |
opcache.revalidate_freq => 2 => 2 | |
opcache.file_update_protection => 0 => 0 | |
opcache.preferred_memory_model => no value => no value | |
opcache.blacklist_filename => no value => no value | |
opcache.max_file_size => 0 => 0 | |
opcache.protect_memory => 0 => 0 | |
opcache.save_comments => 1 => 1 | |
opcache.optimization_level => 0x7FFEBFFF => 0x7FFEBFFF | |
opcache.opt_debug_level => 0 => 0 | |
opcache.enable_file_override => Off => Off | |
opcache.enable_cli => On => On | |
opcache.error_log => no value => no value | |
opcache.restrict_api => no value => no value | |
opcache.lockfile_path => /tmp => /tmp | |
opcache.file_cache => no value => no value | |
opcache.file_cache_only => 0 => 0 | |
opcache.file_cache_consistency_checks => 1 => 1 | |
opcache.huge_code_pages => Off => Off | |
opcache.preload => no value => no value | |
opcache.jit => 1235 => 1235 | |
opcache.jit_buffer_size => 256M => 256M | |
opcache.jit_debug => 0 => 0 |
$ sapi/cli/php -dextension_dir=`pwd`/modules -dzend_extension=opcache.so -dpcre.jit=1 msgpack.php/tests/bench.php | |
============================================= | |
Total 9.8220 4.3121 | |
$ sapi/cli/php -dextension_dir=`pwd`/modules -dzend_extension=opcache.so -dpcre.jit=1 -dopcache.enable_cli=1 -dopcache.jit=1235 -dopcache.file_update_protection=0 -dopcache.jit_buffer_size=256M msgpack.php/tests/bench.php | |
============================================= | |
Total 8.7255 3.3350 |
$ sapi/cli/php -dextension_dir=`pwd`/modules -dzend_extension=opcache.so -dpcre.jit=1 msgpack.php/tests/bench2.php | |
pure msgpack: 2.2818 sec, 17103 bytes | |
pure msgpack packed: 2.1717 sec, 14166 bytes | |
$ sapi/cli/php -dextension_dir=`pwd`/modules -dzend_extension=opcache.so -dpcre.jit=1 -dopcache.enable_cli=1 -dopcache.jit=1235 -dopcache.jit_buffer_size=256M msgpack.php/tests/bench2.php | |
pure msgpack: 1.5221 sec, 17103 bytes | |
pure msgpack packed: 1.4739 sec, 14166 bytes |
$ sapi/cli/php Zend/bench.php | |
------------------------ | |
Total 0.497 | |
$ sapi/cli/php -dextension_dir=`pwd`/modules -dzend_extension=opcache.so Zend/bench.php | |
------------------------ | |
Total 0.488 | |
$ sapi/cli/php -dextension_dir=`pwd`/modules -dzend_extension=opcache.so -dopcache.enable_cli=1 -dopcache.file_update_protection=0 -dopcache.jit_buffer_size=1M Zend/bench.php | |
------------------------ | |
Total 0.118 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment