Имеется два идентичных сервера: Xeon E3-1270v2, 32Gb RAM, RAID10. На одном из них стоит Gentoo Linux запиленная под железо, на другом FreeBSD 10-STABLE. Стало интересно сравнить производительность фри c Linux-ом на типичных серверных задачах: nginx+uwsgi_php55, mariadb-galera, redis. Все кроме php работает замечательно. По результатам теста, php под FreeBSD жрет на 30% больше проца и при этом существенно проигрывает в скорости по сравнению с Linux-ом. Сразу скажу, что на обеих ОСях php собран одной версией компилятора, одинаковыми модулями и с теми же CFLAGS. Прослойка uwsgi никакого влияния не оказывает, пробовал php-fpm - результат тот же. В сетевом стеке или nginx затыка тоже нет (настройки nginx одинаковые). Для уверенности в этом, результат выполнения скрипта клал в htm файл и тащил по сети в 16 потоков, трафик забил гигобитный линк до отказа. Скорость отдачи статики через nginx практически одинаковые на обеих серверах.
В итоге получилось, что на Linux php скрипт (банальный phpinfo()) выполнился за 1 msec, а на фре примерно за 8 msec. Ниже трейсы с временными метками.
12:46:32.578393 accept4(6, {sa_family=AF_INET, sin_port=htons(59528), sin_addr=inet_addr("192.168.3.7")}, [16], SOCK_NONBLOCK) = 10
12:46:32.578527 read(10, "\0167\2\0\17\0SCRIPT_FILENAME+\0/home/htt"..., 4100) = 574
12:46:32.578678 lstat("/home", {st_mode=S_IFDIR|0755, st_size=256, ...}) = 0
12:46:32.578779 lstat("/home/httpd", {st_mode=S_IFDIR|0755, st_size=80, ...}) = 0
12:46:32.578917 lstat("/home/httpd/www", {st_mode=S_IFDIR|0755, st_size=120, ...}) = 0
12:46:32.578966 lstat("/home/httpd/www/system", {st_mode=S_IFDIR|0755, st_size=208, ...}) = 0
12:46:32.579035 lstat("/home/httpd/www/system/web", {st_mode=S_IFDIR|0755, st_size=440, ...}) = 0
12:46:32.579078 stat("/home/httpd/www/system/web", {st_mode=S_IFDIR|0755, st_size=440, ...}) = 0
12:46:32.579124 lstat("/home", {st_mode=S_IFDIR|0755, st_size=256, ...}) = 0
12:46:32.579161 lstat("/home/httpd", {st_mode=S_IFDIR|0755, st_size=80, ...}) = 0
12:46:32.579177 lstat("/home/httpd/www", {st_mode=S_IFDIR|0755, st_size=120, ...}) = 0
12:46:32.579225 lstat("/home/httpd/www/system", {st_mode=S_IFDIR|0755, st_size=208, ...}) = 0
12:46:32.579261 lstat("/home/httpd/www/system/web", {st_mode=S_IFDIR|0755, st_size=440, ...}) = 0
12:46:32.579296 lstat("/home/httpd/www/system/web/info.php", {st_mode=S_IFREG|0644, st_size=20, ...}) = 0
12:46:32.579321 stat("/home/httpd/www/system/web/info.php", {st_mode=S_IFREG|0644, st_size=20, ...}) = 0
12:46:32.579373 setitimer(ITIMER_PROF, {it_interval={0, 0}, it_value={60, 0}}, NULL) = 0
12:46:32.579417 rt_sigaction(SIGPROF, {0x7f67b9b1a0b0, [PROF], SA_RESTORER|SA_RESTART, 0x3654634d10}, {0x7f67b9b1a0b0, [PROF], SA_RESTORER|SA_RESTART, 0x3654634d10}, 8) = 0
12:46:32.579464 rt_sigprocmask(SIG_UNBLOCK, [PROF], NULL, 8) = 0
12:46:32.579517 lstat("/home/httpd/www/system/web", {st_mode=S_IFDIR|0755, st_size=440, ...}) = 0
12:46:32.579535 lstat("/home/httpd/www/system", {st_mode=S_IFDIR|0755, st_size=208, ...}) = 0
12:46:32.579565 lstat("/home/httpd/www", {st_mode=S_IFDIR|0755, st_size=120, ...}) = 0
12:46:32.579588 lstat("/home/httpd", {st_mode=S_IFDIR|0755, st_size=80, ...}) = 0
12:46:32.579608 lstat("/home", {st_mode=S_IFDIR|0755, st_size=256, ...}) = 0
12:46:32.579627 stat("/home/httpd/www/system/web", {st_mode=S_IFDIR|0755, st_size=440, ...}) = 0
12:46:32.579647 setitimer(ITIMER_PROF, {it_interval={0, 0}, it_value={30, 0}}, NULL) = 0
12:46:32.579662 lstat("/home/httpd/www/system/web/info.php", {st_mode=S_IFREG|0644, st_size=20, ...}) = 0
12:46:32.579679 lstat("/home/httpd/www/system/web", {st_mode=S_IFDIR|0755, st_size=440, ...}) = 0
12:46:32.579698 lstat("/home/httpd/www/system", {st_mode=S_IFDIR|0755, st_size=208, ...}) = 0
12:46:32.579715 lstat("/home/httpd/www", {st_mode=S_IFDIR|0755, st_size=120, ...}) = 0
12:46:32.579731 lstat("/home/httpd", {st_mode=S_IFDIR|0755, st_size=80, ...}) = 0
12:46:32.579772 lstat("/home", {st_mode=S_IFDIR|0755, st_size=256, ...}) = 0
12:46:32.579800 stat("/home/httpd/www/system/web/info.php", {st_mode=S_IFREG|0644, st_size=20, ...}) = 0
12:46:32.579816 lstat("/home/httpd/www/system/web/info.php", {st_mode=S_IFREG|0644, st_size=20, ...}) = 0
12:46:32.579831 lstat("/home/httpd/www/system/web", {st_mode=S_IFDIR|0755, st_size=440, ...}) = 0
12:46:32.579864 lstat("/home/httpd/www/system", {st_mode=S_IFDIR|0755, st_size=208, ...}) = 0
12:46:32.579882 lstat("/home/httpd/www", {st_mode=S_IFDIR|0755, st_size=120, ...}) = 0
12:46:32.579899 lstat("/home/httpd", {st_mode=S_IFDIR|0755, st_size=80, ...}) = 0
12:46:32.579917 lstat("/home", {st_mode=S_IFDIR|0755, st_size=256, ...}) = 0
12:46:32.579944 uname({sys="Linux", node="node1", ...}) = 0
12:46:32.581114 write(10, "HTTP/1.1 200 OK\r\nContent-type: t"..., 44) = 44
12:46:32.581141 write(10, "<!DOCTYPE html PUBLIC \"-//W3C//D"..., 95544) = 95544
12:46:32.581178 lstat("/home/httpd/www/system", {st_mode=S_IFDIR|0755, st_size=208, ...}) = 0
12:46:32.581195 lstat("/home/httpd/www", {st_mode=S_IFDIR|0755, st_size=120, ...}) = 0
12:46:32.581213 lstat("/home/httpd", {st_mode=S_IFDIR|0755, st_size=80, ...}) = 0
12:46:32.581232 lstat("/home", {st_mode=S_IFDIR|0755, st_size=256, ...}) = 0
12:46:32.581249 stat("/home/httpd/www/system", {st_mode=S_IFDIR|0755, st_size=208, ...}) = 0
12:46:32.581268 setitimer(ITIMER_PROF, {it_interval={0, 0}, it_value={0, 0}}, NULL) = 0
12:46:32.581298 setitimer(ITIMER_PROF, {it_interval={0, 0}, it_value={0, 0}}, NULL) = 0
12:46:32.581313 open("/proc/self/stat", O_RDONLY) = 13
12:46:32.581333 fstat(13, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
12:46:32.581369 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f67b87bf000
12:46:32.581390 read(13, "5295 (uwsgi) R 5292 5291 5291 0 "..., 1024) = 309
12:46:32.581415 close(13) = 0
12:46:32.581435 munmap(0x7f67b87bf000, 4096) = 0
12:46:32.581452 close(10) = 0
12:46:32.581475 writev(2, [{"{address space usage: 313401344 "..., 78}, {"[pid: 5295|app: -1|req: -1/20] 1"..., 207}], 2) = 285
12:46:32.581516 epoll_wait(8, ^CProcess 5295 detached
<detached ...>
13518: 4.569934535 4.569699769 kevent(7,0x0,0,{0x6,EVFILT_READ,0x0,0,0x1,0x0},1,0x0) = 1 (0x1)
13518: 4.570825352 0.000052122 accept(6,{ AF_INET 192.168.3.8:27225 },0x800751104) = 9 (0x9)
13518: 4.571227700 0.000080451 read(9,"\^N7\^B\0\^O\0SCRIPT_FILENAME+\0"...,4100) = 574 (0x23e)
13518: 4.572505836 0.000127551 lstat("/home",{ mode=drwxr-xr-x ,inode=4,size=6,blksize=4096 }) = 0 (0x0)
13518: 4.572865713 0.000085512 lstat("/home/httpd",{ mode=drwxr-xr-x ,inode=8,size=3,blksize=4096 }) = 0 (0x0)
13518: 4.573190386 0.000084730 lstat("/home/httpd/www",{ mode=drwxr-xr-x ,inode=11,size=7,blksize=4096 }) = 0 (0x0)
13518: 4.573510820 0.000085387 lstat("/home/httpd/www/system",{ mode=drwxr-xr-x ,inode=14,size=8,blksize=4096 }) = 0 (0x0)
13518: 4.573830457 0.000086490 lstat("/home/httpd/www/system/web",{ mode=drwxr-xr-x ,inode=110568,size=15,blksize=4096 }) = 0 (0x0)
13518: 4.574463050 0.000112191 stat("/home/httpd/www/system/web",{ mode=drwxr-xr-x ,inode=110568,size=15,blksize=4096 }) = 0 (0x0)
13518: 4.574776573 0.000074341 lstat("/home",{ mode=drwxr-xr-x ,inode=4,size=6,blksize=4096 }) = 0 (0x0)
13518: 4.575283320 0.000147897 lstat("/home/httpd",{ mode=drwxr-xr-x ,inode=8,size=3,blksize=4096 }) = 0 (0x0)
13518: 4.575610283 0.000083883 lstat("/home/httpd/www",{ mode=drwxr-xr-x ,inode=11,size=7,blksize=4096 }) = 0 (0x0)
13518: 4.575931248 0.000084239 lstat("/home/httpd/www/system",{ mode=drwxr-xr-x ,inode=14,size=8,blksize=4096 }) = 0 (0x0)
13518: 4.576285572 0.000108849 lstat("/home/httpd/www/system/web",{ mode=drwxr-xr-x ,inode=110568,size=15,blksize=4096 }) = 0 (0x0)
13518: 4.576609324 0.000111585 lstat("/home/httpd/www/system/web/info.php",{ mode=-rw-r--r-- ,inode=102419,size=20,blksize=4096 }) = 0 (0x0)
13518: 4.576934252 0.000087095 stat("/home/httpd/www/system/web/info.php",{ mode=-rw-r--r-- ,inode=102419,size=20,blksize=4096 }) = 0 (0x0)
13518: 4.578137551 0.000044300 setitimer(2,{0.000000, 60.000000 },0x0) = 0 (0x0)
13518: 4.578890119 0.000065843 sigprocmask(SIG_SETMASK,SIGHUP|SIGINT|SIGQUIT|SIGILL|SIGTRAP|SIGABRT|SIGEMT|SIGFPE|SIGKILL|SIGBUS|SIGSEGV|SIGSYS|SIGPIPE|SIGALRM|SIGTERM|SIGURG|SIGSTOP|SIGTSTP|SIGCONT|SIGCHLD|SIGTTIN|SIGTTOU|SIGIO|SIGXCPU|SIGXFSZ|SIGVTALRM|SIGPROF|SIGWINCH|SIGINFO|SIGUSR1|SIGUSR2,0x0) = 0 (0x0)
13518: 4.579187695 0.000043938 sigaction(SIGPROF,{ 0x8008c4f10 SA_RESTART|SA_SIGINFO ss_t },{ SIG_DFL SA_RESTART ss_t }) = 0 (0x0)
13518: 4.579462247 0.000041825 sigprocmask(SIG_SETMASK,0x0,0x0) = 0 (0x0)
13518: 4.579911068 0.000042550 sigprocmask(SIG_UNBLOCK,SIGPROF,0x0) = 0 (0x0)
13518: 4.590744228 0.000042902 getpid() = 13518 (0x34ce)
13518: 4.591336110 0.000120646 lstat("/home/httpd/www/system/web",{ mode=drwxr-xr-x ,inode=110568,size=15,blksize=4096 }) = 0 (0x0)
13518: 4.591654258 0.000083637 lstat("/home/httpd/www/system",{ mode=drwxr-xr-x ,inode=14,size=8,blksize=4096 }) = 0 (0x0)
13518: 4.591972362 0.000081378 lstat("/home/httpd/www",{ mode=drwxr-xr-x ,inode=11,size=7,blksize=4096 }) = 0 (0x0)
13518: 4.592261019 0.000077203 lstat("/home/httpd",{ mode=drwxr-xr-x ,inode=8,size=3,blksize=4096 }) = 0 (0x0)
13518: 4.592546414 0.000053455 lstat("/home",{ mode=drwxr-xr-x ,inode=4,size=6,blksize=4096 }) = 0 (0x0)
13518: 4.593027172 0.000087156 stat("/home/httpd/www/system/web",{ mode=drwxr-xr-x ,inode=110568,size=15,blksize=4096 }) = 0 (0x0)
13518: 4.593343938 0.000042315 setitimer(2,{0.000000, 30.000000 },0x0) = 0 (0x0)
13518: 4.593741569 0.000111314 lstat("/home/httpd/www/system/web/info.php",{ mode=-rw-r--r-- ,inode=102419,size=20,blksize=4096 }) = 0 (0x0)
13518: 4.594713138 0.000122570 open("/home/httpd/www/system/web/info.php",O_RDONLY,00) = 11 (0xb)
13518: 4.595143348 0.000071575 fstat(11,{ mode=-rw-r--r-- ,inode=102419,size=20,blksize=4096 }) = 0 (0x0)
13518: 4.595421016 0.000066014 lseek(11,0x0,SEEK_CUR) = 0 (0x0)
13518: 4.595870293 0.000074647 read(11,"<?php\nphpinfo();\n?>\n",8192) = 20 (0x14)
13518: 4.596238890 0.000046159 read(11,0x7dc8e8,8192) = 0 (0x0)
13518: 4.596512268 0.000044300 read(11,0x7dc8e8,8192) = 0 (0x0)
13518: 4.596948686 0.000071119 close(11) = 0 (0x0)
13518: 4.600002706 0.000046740 break(0xd44000) = 0 (0x0)
13518: 4.604407899 0.000144809 open("/home/httpd/www/system/web/info.php",O_RDONLY,00) = 11 (0xb)
13518: 4.604657610 0.000047382 fstat(11,{ mode=-rw-r--r-- ,inode=102419,size=20,blksize=4096 }) = 0 (0x0)
13518: 4.604905881 0.000046504 __sysctl(0x7fffffffb380,0x2,0x7fffffffb37c,0x7fffffffb388,0x0,0x0) = 0 (0x0)
13518: 4.605218127 0.000046154 fstat(11,{ mode=-rw-r--r-- ,inode=102419,size=20,blksize=4096 }) = 0 (0x0)
13518: 4.605494952 0.000044314 fstat(11,{ mode=-rw-r--r-- ,inode=102419,size=20,blksize=4096 }) = 0 (0x0)
13518: 4.605771958 0.000076125 mmap(0x0,20,PROT_READ,MAP_SHARED,11,0x0) = 34367475712 (0x800761000)
13518: 4.607110165 0.000039308 getpid() = 13518 (0x34ce)
13518: 4.609585731 0.000076692 munmap(0x800761000,20) = 0 (0x0)
13518: 4.609831733 0.000072562 close(11) = 0 (0x0)
13518: 4.610278029 0.000047472 __sysctl(0x7fffffffbfe0,0x2,0x7fffffffc130,0x7fffffffbfd8,0x0,0x0) = 0 (0x0)
13518: 4.610554860 0.000044264 __sysctl(0x7fffffffbfe0,0x2,0x7fffffffc230,0x7fffffffbfd8,0x0,0x0) = 0 (0x0)
13518: 4.610830052 0.000066649 __sysctl(0x7fffffffbfe0,0x2,0x7fffffffc330,0x7fffffffbfd8,0x0,0x0) = 0 (0x0)
13518: 4.611107379 0.000067807 __sysctl(0x7fffffffbfe0,0x2,0x7fffffffc430,0x7fffffffbfd8,0x0,0x0) = 0 (0x0)
13518: 4.611396603 0.000042516 __sysctl(0x7fffffffbfe0,0x2,0x7fffffffc530,0x7fffffffbfd8,0x0,0x0) = 0 (0x0)
13518: 4.616492616 0.000155860 open("/usr/share/locale/en_US.UTF-8/LC_CTYPE",O_CLOEXEC,0666) = 11 (0xb)
13518: 4.616764816 0.000070753 fstat(11,{ mode=-r--r--r-- ,inode=132288,size=76132,blksize=65536 }) = 0 (0x0)
13518: 4.617088612 0.000069731 fstat(11,{ mode=-r--r--r-- ,inode=132288,size=76132,blksize=65536 }) = 0 (0x0)
13518: 4.617405293 0.000064435 lseek(11,0x0,SEEK_CUR) = 0 (0x0)
13518: 4.617650067 0.000043323 lseek(11,0x0,SEEK_SET) = 0 (0x0)
13518: 4.618217554 0.000365490 read(11,"RuneMag1UTF-8\0\0\0\0\0\0\0\0\0"...,65536) = 65536 (0x10000)
13518: 4.619179546 0.000082154 read(11,"@\^D\b\0@\^D\b\0@\^D\b\0@\^D\b\0"...,65536) = 10596 (0x2964)
13518: 4.620830499 0.000050112 close(11) = 0 (0x0)
13518: 4.624148825 0.000068403 break(0xe44000) = 0 (0x0)
13518: 4.630655933 0.000126919 open("/usr/share/locale/en_US.UTF-8/LC_CTYPE",O_CLOEXEC,0666) = 11 (0xb)
13518: 4.630926550 0.000070057 fstat(11,{ mode=-r--r--r-- ,inode=132288,size=76132,blksize=65536 }) = 0 (0x0)
13518: 4.631176742 0.000045122 fstat(11,{ mode=-r--r--r-- ,inode=132288,size=76132,blksize=65536 }) = 0 (0x0)
13518: 4.631422162 0.000043784 lseek(11,0x0,SEEK_CUR) = 0 (0x0)
13518: 4.631664936 0.000042445 lseek(11,0x0,SEEK_SET) = 0 (0x0)
13518: 4.632011403 0.000119448 read(11,"RuneMag1UTF-8\0\0\0\0\0\0\0\0\0"...,65536) = 65536 (0x10000)
13518: 4.632747574 0.000079103 read(11,"@\^D\b\0@\^D\b\0@\^D\b\0@\^D\b\0"...,65536) = 10596 (0x2964)
13518: 4.633894601 0.000069425 close(11) = 0 (0x0)
13518: 4.638873827 0.000109916 write(9,"HTTP/1.1 200 OK\r\nContent-type:"...,44) = 44 (0x2c)
13518: 4.639321908 0.000170057 write(9,"<!DOCTYPE html PUBLIC "-//W3C//D"...,85600) = 81616 (0x13ed0)
13518: 4.640090226 0.000052438 poll({9/POLLOUT},1,4000) = 1 (0x1)
13518: 4.640748743 0.000099664 write(9,"ance, Johann Hanne, Boris Lytoch"...,3984) = 3984 (0xf90)
13518: 4.641393844 0.000129956 stat("/home/httpd/www/system/web",{ mode=drwxr-xr-x ,inode=110568,size=15,blksize=4096 }) = 0 (0x0)
13518: 4.641877614 0.000042891 setitimer(2,{0.000000, 0.000000 },0x0) = 0 (0x0)
13518: 4.642830145 0.000041974 getpid() = 13518 (0x34ce)
13518: 4.643472691 0.000042961 setitimer(2,{0.000000, 0.000000 },0x0) = 0 (0x0)
13518: 4.644000590 0.000077829 __sysctl(0x7fffffffd3d8,0x2,0x8027e0db0,0x7fffffffd3e0,0x0,0x0) = 0 (0x0)
13518: 4.644593565 0.000113284 open("/dev/null",O_CLOEXEC,00) = 11 (0xb)
13518: 4.645078362 0.000070653 fstat(11,{ mode=crw-rw-rw- ,inode=25,size=0,blksize=4096 }) = 0 (0x0)
13518: 4.645558775 0.000077133 open("/dev/null",O_CLOEXEC,00) = 12 (0xc)
13518: 4.645971445 0.000092082 __sysctl(0x7fffffffd470,0x4,0x0,0x7fffffffd460,0x0,0x0) = 0 (0x0)
13518: 4.646439044 0.000119022 __sysctl(0x7fffffffd470,0x4,0x7e9900,0x7fffffffd460,0x0,0x0) = 0 (0x0)
13518: 4.646921601 0.000071426 close(11) = 0 (0x0)
13518: 4.647215820 0.000041939 close(12) = 0 (0x0)
13518: 4.647561215 0.000079659 close(9) = 0 (0x0)
13518: 4.648209339 0.000112332 writev(0x2,0x7fffffffb470,0x2,0x8ad8d7b1a524b1c9,0x7fffffb93526,0x8025b0de0) = 286 (0x11e)
Не совсем понятно зачем php под фрей запрашивает кучу sysctl да еще и зачем-то в /dev/null лезет. Можно ли это как-то выпилить?
Подскажите пожалуйста куда копать. Если нужна доп. инфа о настройках FreeBSD - пишите.