dd-trace-php icon indicating copy to clipboard operation
dd-trace-php copied to clipboard

[Feature] profiling `ZTS` builds

Open sumerc opened this issue 2 years ago • 9 comments
trafficstars

Hi,

Is supporting zts builds something planned for the future, is there any issue for this? Sorry, if this is already discussed, but I can not seem to find an issue for that.

sumerc avatar May 22 '23 15:05 sumerc

Which product are you asking for?

  • Appsec supports ZTS.
  • Tracing supports ZTS.
  • Profiling does not support ZTS and doesn't have an ETA.

morrisonlevi avatar May 22 '23 15:05 morrisonlevi

It was for profiling. Thanks for the info!

What is the main reason behind the complexity?. Maybe we might think to work on it if we understand the underlying problem?

sumerc avatar May 22 '23 16:05 sumerc

May I ask what you are using ZTS builds for? What libraries and such are you using?

Some of the complexity is that the PHP ABIs change for ZTS. The C macros that C extensions use don't always help since the profiler is primarily written in Rust. It's possible to support, I think, and is more of a matter of priority. Understanding what you are using ZTS builds for can help us understand the priority.

morrisonlevi avatar May 22 '23 17:05 morrisonlevi

We are thinking of integrating continuous profiling for https://docs.platform.sh/languages/php.html. And it currently uses ZTS.

sumerc avatar May 24 '23 08:05 sumerc

I wanted to use frankenphp as replacement for php-fpm+nginx. It is a ZTS build. Installer does not allow profiling. I liked how profiling worked with php-fpm and would be nice if it was available with ZTS.

$ docker build . -f Dockerfile-frankenphp                                            
...
------                                                                                                                                                                                                                                                                                                                      
 > [stage-0 4/4] RUN php /datadog-setup.php --php-bin=all --enable-profiling:                                                                                                                                                                                                                                               
0.536 Searching for available php binaries, this operation might take a while.                                                                                                                                                                                                                                              
0.666 Downloading installable archive from https://github.com/DataDog/dd-trace-php/releases/download/0.96.0/dd-library-php-0.96.0-x86_64-linux-gnu.tar.gz.                                                                                                                                                                  
0.666 This operation might take a while.                                                                                                                                                                                                                                                                                    
1.620 ...................                                                                                                                                                                                                                                                                                                   
8.662 Download completed
8.662 
12.51 Installed required source files to '/opt/datadog/dd-library/0.96.0'
12.57 Installing to binary: php (/usr/local/bin/php)
12.66 Copied '/tmp/dd-install/dd-library-php/trace/ext/20230831/ddtrace-zts.so' to '/usr/local/lib/php/extensions/no-debug-zts-20230831/ddtrace.so'
12.66 Copied '/tmp/dd-install/dd-library-php/appsec/ext/20230831/ddappsec-zts.so' to '/usr/local/lib/php/extensions/no-debug-zts-20230831/ddappsec.so'
12.66 Created INI file '/usr/local/etc/php/conf.d/98-ddtrace.ini'
12.66 ERROR: Option --enable-profiling was provided, but it is not supported on this PHP build or version.
12.66 
------
Dockerfile-frankenphp:6
--------------------
   4 |     ADD https://github.com/DataDog/dd-trace-php/releases/download/0.96.0/datadog-setup.php /datadog-setup.php
   5 |     
   6 | >>> RUN php /datadog-setup.php --php-bin=all --enable-profiling
   7 |     
--------------------
ERROR: failed to solve: process "/bin/bash -o pipefail -c php /datadog-setup.php --php-bin=all --enable-profiling" did not complete successfully: exit code: 1

piotrekkr avatar Jan 06 '24 21:01 piotrekkr

Hey @sumerc / @piotrekkr,

I just wanted to let you know that I'll working on bringing ZTS support to the profiler. A first PR to make it compile is already there, more to follow. I'll keep you posted.

Kind regards Florian

realFlowControl avatar Jan 15 '24 10:01 realFlowControl

Thanks for the update!

sumerc avatar Jan 15 '24 10:01 sumerc

Cool. Can't wait :+1:

piotrekkr avatar Jan 15 '24 13:01 piotrekkr

Hey @sumerc / @piotrekkr,

we just released 0.98.0 which brings ZTS (more or less as private beta) support for CPU and Wall time profiling including timeline. I have also tested this with FrankenPHP! I have not yet tested Exception Profiling, but it seems to work, I'll make this sure for a later release and I am currently working on making allocation profiling thread safe in https://github.com/DataDog/dd-trace-php/pull/2506, in the mean time allocation profiling is intentionally disabled on ZTS PHP as it would crash. There will also be some work done by me to better support FrankenPHP's worker mode in https://github.com/DataDog/dd-trace-php/pull/2523.

Let me know how this works for you!

Kind regards Florian

realFlowControl avatar Feb 20 '24 10:02 realFlowControl

Hey there 👋

0.99 just got released and brings ZTS support for exception, as well as allocation profiling and FrankenPHP support (including worker mode) 🎉

The tracer also added support for FrankenPHP into this release.

Thanks everyone for your patience 🙏 and in case you find anything, please open a Github Issue or reach out to support.

realFlowControl avatar Apr 04 '24 07:04 realFlowControl