php icon indicating copy to clipboard operation
php copied to clipboard

Default dtrace support

Open axot opened this issue 5 years ago • 6 comments

I'm considering is there any reason why dtrace was disabled by default?

axot avatar Apr 12 '19 14:04 axot

We considered it for python over in https://github.com/docker-library/python/pull/366 (:wave: @tgross!), but after doing performance testing it was found to have an unfortunately negative effect.

Perhaps something similar could be done here to verify the impact? (Also worth checking whether a packager like Debian includes this, but they likely don't currently.)

tianon avatar Apr 12 '19 15:04 tianon

I did a simple benchmark which enables/disables dtrace at build time, the result shows there is no significant difference.

$ 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" \

The 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

axot avatar Apr 19 '19 13:04 axot

Ah, interesting! Unlike python, PHP threw this functionality behind a feature flag environment variable to help insulate against the performance overhead; neat!

Looks like that was added back in 7.1.0:

- DTrace:
  . Disabled PHP call tracing by default (it makes significant overhead).
    This may be enabled again using envirionment variable USE_ZEND_DTRACE=1.
    (Dmitry)

So the impact is significant, but still optional. I will note though that I have been looking for a better PHP benchmark than Zend/bench.php (I used it a lot to try and chase down https://github.com/docker-library/php/issues/493 and/or https://github.com/docker-library/php/pull/753) as I found it to be horribly insufficient to get a real decent view of PHP's performance (so the fact that it's noticeable even there is an indicator of likely a much larger impact elsewhere).

tianon avatar Apr 19 '19 21:04 tianon

I remember PHP internal did some benchmark for older PHP, like this one, http://languagesperformance.intel.com/good-benchmark-results-for-php-master-2017-09-10/

NIGHTLY BUILDS: ZEND PHP ENVIRONMENT SETUP, https://01.org/node/3774

axot avatar Apr 25 '19 10:04 axot

Hey people; I ended up here after some research and would like to bring up the topic again, as the issue is not yet resolved. Are there any plans on enabling dtrace by default? Does it make sense to submit a Pull Request? (Maybe @axot could do it if time fits, as the diff was already provided)

nawarian avatar Jan 22 '20 12:01 nawarian

I think it needs someone to set up a better benchmark than Zend/bench.php (more thorough and/or more realistic) and verify that the opt-out performance is still reasonable on a heavier or more real workload.

https://01.org/node/3774 looks very promising, but rather involved.

tianon avatar Feb 14 '20 00:02 tianon