Last active
July 30, 2018 02:29
-
-
Save php-cpm/ac7fd10c84894320e364e7e54ccc93b6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
first benchmark is redis | |
<?php | |
$redis = new Redis(); | |
$redis->connect('127.0.0.1', 6379); | |
for ($i = 0; $i < 100; $i++) { | |
$start = microtime(true); | |
for ($j = 0; $j < 10000; $j++) { | |
$key = sprintf("key:%05d", $j); | |
$redis->pipeline(); | |
/* GET or SET */ | |
if (rand() % 2 == 0) { | |
$redis->set($key, rand()); | |
} else { | |
$redis->get($key); | |
} | |
} | |
$time = microtime(true)-$start; | |
printf("%6d req/sec\n", $j/$time); | |
} |
use strace to analise sys call sudo dtruss -c php redis.php
predis
CALL COUNT
bsdthread_register 1
connect 1
fchmod 1
ftruncate 1
getentropy 1
getpid 1
getrlimit 1
getsockopt 1
getuid 1
shm_open 1
sigprocmask 1
thread_selfid 1
write 1
csops 2
fstatat64 2
fstatfs64 2
getegid 2
gettid 2
issetugid 2
openat_nocancel 2
unlink 2
geteuid 3
socket 3
getdirentries64 4
sysctl 4
fcntl_nocancel 6
madvise 6
pread 12
mprotect 17
readlink 17
read_nocancel 19
access 28
lseek 41
open 42
close 45
sigaction 45
close_nocancel 49
open_nocancel 52
lstat64 54
munmap 64
ioctl 73
fcntl 74
stat64 86
mmap 104
getattrlist 132
fstat64 146
recvfrom 8390
sendto 8390
poll 8391
predis calls more recvfrom
sendto
so it's a little slower than others
php-ext-redis
bsdthread_register 1
connect 1
fchmod 1
ftruncate 1
getentropy 1
getpid 1
getrlimit 1
getsockopt 1
getuid 1
shm_open 1
sigprocmask 1
thread_selfid 1
csops 2
fstatat64 2
fstatfs64 2
getegid 2
gettid 2
issetugid 2
openat_nocancel 2
unlink 2
access 3
geteuid 3
socket 3
getdirentries64 4
sysctl 4
fcntl_nocancel 5
madvise 6
pread 12
lstat64 13
open 13
close 16
fcntl 16
mprotect 17
readlink 17
read_nocancel 19
munmap 35
lseek 41
sigaction 45
close_nocancel 48
open_nocancel 51
stat64 56
fstat64 58
ioctl 73
mmap 75
getattrlist 132
sendto 1596
setsockopt 1597
recvfrom 1598
poll 6382
php-ext-memcached
bsdthread_register 1
connect 1
fchmod 1
ftruncate 1
getentropy 1
getpid 1
getrlimit 1
getsockopt 1
getuid 1
setsockopt 1
shm_open 1
sigprocmask 1
thread_selfid 1
write 1
csops 2
fstatat64 2
fstatfs64 2
getegid 2
gettid 2
issetugid 2
openat_nocancel 2
socket 2
unlink 2
access 3
geteuid 3
getdirentries64 4
sysctl 4
fcntl_nocancel 5
madvise 6
pread 12
lstat64 13
open 13
close 15
fcntl 17
mprotect 17
readlink 17
read_nocancel 19
munmap 35
lseek 41
sigaction 45
close_nocancel 48
open_nocancel 51
stat64 56
fstat64 58
ioctl 73
mmap 75
getattrlist 132
poll 2550
sendto 2552
recvfrom 5103
php connect to redis using a lot of poll
when memcached using recvform code recvfrom(0x4, 0x7FC86509E2B8, 0x2004) = -1 Err#35
which means Resource deadlock avoided
php-ext-apcu
CALL COUNT
bsdthread_register 1
exit 1
fchmod 1
ftruncate 1
getentropy 1
getpid 1
getrlimit 1
getuid 1
shm_open 1
sigprocmask 1
socket 1
thread_selfid 1
csops 2
fstatat64 2
fstatfs64 2
getegid 2
gettid 2
issetugid 2
openat_nocancel 2
unlink 2
access 3
geteuid 3
getdirentries64 4
sysctl 4
fcntl_nocancel 5
pread 12
lstat64 13
open 13
fcntl 14
close 16
mprotect 17
readlink 17
read_nocancel 19
lseek 41
sigaction 45
open_nocancel 50
close_nocancel 51
stat64 56
fstat64 58
ioctl 73
mmap 75
write 101
getattrlist 132
munmap 140
madvise 232
apcu memory operation calling madvise
, munmap
, etc.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
check for avg
use same program
change cache type
change cache data
run benchmark again and again
(json_encode/serialize)
based on this report we suggest people use
even more hard sence
redis pconnect reuse 21710.55