Topic: php enabled DTrace by default

We are discussing is it possible to enable DTrace for PHP

https://github.com/docker-library/php/issues/813

I noticed the rpm package which remi built is enabled DTrace,
so we want to know is there any benchmark result for on/off DTrace.

The performace result of python which on/off DTrace,
26 of the 60 tests show a 5%-17% performance hit.

Thanks.

Re: php enabled DTrace by default

dtrace is enabled at buildtime since if have no cost at runtime if not explicitly enabled setting USE_ZEND_DTRACE=1 in the environment (Since PHP 7.0.14, this was not true with PHP 5).

IN NEWS File

- DTrace:
  . Disabled PHP call tracing by default (it makes significant overhead).
    This may be enabled again using envirionment variable USE_ZEND_DTRACE=1.
    (Dmitry)
Laptop:  Fedora 38 + rpmfusion + remi (SCL only)
x86_64 builder: Fedora 39 + rpmfusion + remi-test
aarch64 builder: RHEL 9 with EPEL
Hosting Server: CentOS 8 Stream with EPEL, rpmfusion, remi

Re: php enabled DTrace by default

I checked out the spec file of 7.2.17, it shows dtrace support is enabled at compile time.

%global with_dtrace  1

%if %{with_dtrace}
    --enable-dtrace \
%endif

Re: php enabled DTrace by default

Have you read my answer ?

"dtrace is enabled at buildtime since if have no cost at runtime"

Laptop:  Fedora 38 + rpmfusion + remi (SCL only)
x86_64 builder: Fedora 39 + rpmfusion + remi-test
aarch64 builder: RHEL 9 with EPEL
Hosting Server: CentOS 8 Stream with EPEL, rpmfusion, remi

Re: php enabled DTrace by default

To summarize

$ php -n Zend/bench.php 
simple             0.025
simplecall         0.007
simpleucall        0.017
simpleudcall       0.019
mandel             0.071
mandel2            0.086
ackermann(7)       0.017
ary(50000)         0.004
ary2(50000)        0.003
ary3(2000)         0.041
fibo(30)           0.061
hash1(50000)       0.009
hash2(500)         0.007
heapsort(20000)    0.020
matrix(20)         0.020
nestedloop(12)     0.040
sieve(30)          0.014
strcat(200000)     0.004
------------------------
Total              0.464

$ USE_ZEND_DTRACE=1  php -n Zend/bench.php 
simple             0.024
simplecall         0.008
simpleucall        0.023
simpleudcall       0.025
mandel             0.071
mandel2            0.086
ackermann(7)       0.025
ary(50000)         0.004
ary2(50000)        0.003
ary3(2000)         0.041
fibo(30)           0.081
hash1(50000)       0.010
hash2(500)         0.007
heapsort(20000)    0.019
matrix(20)         0.020
nestedloop(12)     0.040
sieve(30)          0.014
strcat(200000)     0.004
------------------------
Total              0.506
Laptop:  Fedora 38 + rpmfusion + remi (SCL only)
x86_64 builder: Fedora 39 + rpmfusion + remi-test
aarch64 builder: RHEL 9 with EPEL
Hosting Server: CentOS 8 Stream with EPEL, rpmfusion, remi

6 (edited by axot 2019-04-19 13:50:44)

Re: php enabled DTrace by default

Hello, Thank you for the explanation, I also did a test which enables/disables dtrace at build time, the result shows there are no significant difference as you said

Compile options (https://github.com/docker-library/php.git)

$ git diff
diff --git i/7.2/stretch/cli/Dockerfile w/7.2/stretch/cli/Dockerfile
index b229a2d..f607223 100644
--- i/7.2/stretch/cli/Dockerfile
+++ w/7.2/stretch/cli/Dockerfile
@@ -26,7 +26,8 @@ ENV PHPIZE_DEPS \
                libc-dev \
                make \
                pkg-config \
-               re2c
+               re2c \
+               systemtap-sdt-dev

 # persistent / runtime deps
 RUN apt-get update && apt-get install -y \
@@ -95,7 +96,7 @@ RUN set -xe; \
                wget -O php.tar.xz.asc "$PHP_ASC_URL"; \
                export GNUPGHOME="$(mktemp -d)"; \
                for key in $GPG_KEYS; do \
-                       gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \
+                       gpg --batch --keyserver ipv4.pool.sks-keyservers.net --recv-keys "$key"; \
                done; \
                gpg --batch --verify php.tar.xz.asc php.tar.xz; \
                command -v gpgconf > /dev/null && gpgconf --kill all; \
@@ -150,6 +151,7 @@ RUN set -eux; \
                ln -sT "/usr/include/$debMultiarch/curl" /usr/local/include/curl; \
        fi; \
        ./configure \
+               --enable-dtrace \
                --build="$gnuArch" \
                --with-config-file-path="$PHP_INI_DIR" \
                --with-config-file-scan-dir="$PHP_INI_DIR/conf.d" \

Results,

WIth --enable-dtrace

root@6c3b47d93ee5:/usr/local/include/php# php -n Zend/bench.php
simple             0.054
simplecall         0.010
simpleucall        0.020
simpleudcall       0.020
mandel             0.166
mandel2            0.172
ackermann(7)       0.031
ary(50000)         0.006
ary2(50000)        0.005
ary3(2000)         0.043
fibo(30)           0.084
hash1(50000)       0.013
hash2(500)         0.010
heapsort(20000)    0.032
matrix(20)         0.030
nestedloop(12)     0.090
sieve(30)          0.016
strcat(200000)     0.006
------------------------
Total              0.806

root@6c3b47d93ee5:/usr/local/include/php# USE_ZEND_DTRACE=1  php -n Zend/bench.php
simple             0.053
simplecall         0.009
simpleucall        0.025
simpleudcall       0.027
mandel             0.164
mandel2            0.172
ackermann(7)       0.042
ary(50000)         0.004
ary2(50000)        0.003
ary3(2000)         0.046
fibo(30)           0.115
hash1(50000)       0.015
hash2(500)         0.014
heapsort(20000)    0.036
matrix(20)         0.034
nestedloop(12)     0.096
sieve(30)          0.019
strcat(200000)     0.007
------------------------
Total              0.883

Without --enable-dtrace

root@4e09afa52cb4:/usr/local/include/php# php Zend/bench.php
simple             0.054
simplecall         0.008
simpleucall        0.020
simpleudcall       0.020
mandel             0.174
mandel2            0.171
ackermann(7)       0.030
ary(50000)         0.004
ary2(50000)        0.005
ary3(2000)         0.042
fibo(30)           0.080
hash1(50000)       0.012
hash2(500)         0.009
heapsort(20000)    0.031
matrix(20)         0.030
nestedloop(12)     0.089
sieve(30)          0.015
strcat(200000)     0.006
------------------------
Total              0.801

root@4e09afa52cb4:/usr/local/include/php# USE_ZEND_DTRACE=1  php -n Zend/bench.php
simple             0.053
simplecall         0.008
simpleucall        0.019
simpleudcall       0.022
mandel             0.173
mandel2            0.173
ackermann(7)       0.029
ary(50000)         0.004
ary2(50000)        0.003
ary3(2000)         0.041
fibo(30)           0.081
hash1(50000)       0.014
hash2(500)         0.012
heapsort(20000)    0.031
matrix(20)         0.029
nestedloop(12)     0.089
sieve(30)          0.016
strcat(200000)     0.005
------------------------
Total              0.804