ddev / ddev

Docker-based local PHP+Node.js web development environments
https://ddev.com
Apache License 2.0
2.76k stars 603 forks source link

Extend available profilers with SPX profiler #3850

Closed morvy closed 2 years ago

morvy commented 2 years ago

Is there an existing issue for this?

Is your feature request related to a problem? Please describe

Currently there are options to profile the web application with XHprof, XDebug and Blackfire (possibly New Relic with some tutorials seen here in issues). Would it be possible to add SPX profiler, which is something between XHprof and XDebug? Installing it locally is easy, but I can't get it to work through Dockerfile. Main advantage (for me) compared to XHprof is easier to understand GUI, timeline and highlighting function in it.

https://github.com/NoiseByNorthwest/php-spx

Describe the solution you'd like

Have the spx.so precompiled and ready to use, be able to run ddev spx on and open the dashboard on project.ddev.site/spx

Describe alternatives you've considered

No response

Additional context

No response

rfay commented 2 years ago

If you can pioneer this it can make it in.

Start with this .ddev/web-build/Dockerfile:

ARG BASE_IMAGE
FROM $BASE_IMAGE

ENV PHP_VERSION=7.4
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y -o Dpkg::Options::="--force-confnew" --no-install-recommends --no-install-suggests build-essential make autoconf libc-dev pkg-config php-pear php${PHP_VERSION}-dev zlib1g-dev
RUN mkdir -p /tmp/php-spx && cd /tmp/php-spx && git clone -b release/latest https://github.com/NoiseByNorthwest/php-spx.git . &&  phpize && ./configure && make && make install
RUN echo "extension=spx.so" > /etc/php/$PHP_VERSION/mods-available/spx.ini

That assumes php 7.4 of course, so make sure the project is using 7.4. ddev config --php-version=7.4 Then

Now you can experiment inside the container or with ddev exec to do whatever you want.

Now you can experiment with a custom command based on https://github.com/drud/ddev/blob/master/pkg/ddevapp/global_dotddev_assets/commands/web/xhprof and https://github.com/drud/ddev/blob/master/containers/ddev-webserver/ddev-webserver-base-files/usr/local/bin/enable_xhprof (but they should be the one script, spx instead of being spread over two)

morvy commented 2 years ago

Didn't have time to play much with it, but at least I tried it with different PHP versions and everything compiles and runs fine with every PHP version that is available in DDEV. Enabling/Disabling is a bit complicated as it needs to be added to php.ini and triggered with cookie. I'll be playing with it and I'll try to find the best way to run it

rfay commented 2 years ago

This would be a welcome add-on, which you can create and experiment with yourself. If people chime in and want yet another profiler it can be undertaken in the future, but I'm going to close it for now. But if you want to do a PR after living with an add-on for a while it will be fine. Happy to continue the conversation here or elsewhere, but closing for now.

nickchomey commented 5 months ago

@morvy Did you ever figure out a good workflow for SPX with DDEV? I just discovered it and it looks extremely impressive

rfay commented 5 months ago

If you're interested in profiling, do try https://github.com/ddev/ddev-xhgui.

morvy commented 5 months ago

@nickchomey I'm not very good in finishing tasks, so this is still in the same phase. I'm using the code Randy provided, which works just fine ..

longwave commented 1 month ago

We built this as an addon and released it at https://github.com/fullfatthings/ddev-spx

morvy commented 1 month ago

I'm thinking what would be the best command to start the UI. ddev spx is alias for ddev spx on so that won't work and ddev launch -s isn't easy to remember. Is ddev spx ui or ddev spx launch a bad idea?

rfay commented 4 weeks ago

launch is probably too ambiguous. ddev spx ui is interesting.