lando / lando

A development tool for all your projects that is fast, easy, powerful and liberating
https://lando.dev
GNU General Public License v3.0
4.09k stars 545 forks source link

Fast xdebug profiling on/off toggling #1954

Closed hkirsman closed 1 year ago

hkirsman commented 4 years ago

Please explain your request and its importance in the form of a user story.

As a lando user who works with Drupal sites you sometimes need to profile your code to see what part of code takes longer time to execute. XDebug allows you to dump cachegrind file and then you can open it for example with KCachegrind https://kcachegrind.github.io/html/Home.html

It's possible to enable this feature in Lando if you define custom php.ini location and enable xdebug:

config:
  webroot: web
  php: '7.2'
  config:
    php: .lando/php.ini
  xdebug: true

And then in .lando/php.ini (I've added also max_execution_time as the site gets slower with this enabled).

max_execution_time = 300

# XDebug Profiling
xdebug.profiler_enable = 1
xdebug.profiler_output_dir = "/app"
xdebug.profiler_output_name = cachegrind.out.%u.%p.%r.%s

And then ofcourse:

lando rebuild

Is your feature request related to a problem? Please describe. Problem is the speed of how to set this feature up and when done, also the removal part.

Describe the solution you'd like This is solution that would already work - to have lando profiling-on and lando profiling-off command. This is based on https://github.com/lando/lando/issues/1668

tooling:
  profiling-on:
    service: appserver
    description: Enable XDebug profiling for Apache.
    cmd: "docker-php-ext-enable xdebug &&  echo 'max_execution_time=300' > z && echo 'xdebug.profiler_enable=1 >> z && echo 'xdebug.profiler_output_dir=/app >> z && echo 'xdebug.profiler_output_name=cachegrind.out.%u.%p.%r.%s' >> z && mv z /usr/local/etc/php/conf.d/zzz-lando-xdebug-profiling.ini && service apache2 reload"
    user: root
  profiling-off:
    service: appserver
    description: Disable XDebug profiling for Apache.
    cmd: "rm /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini && rm /usr/local/etc/php/conf.d/zzz-lando-xdebug-profiling.ini && service apache2 reload"
    user: root

Describe alternatives you've considered Alternative would be to install some tool on the server like New Relic and profile the code on the go.

Additional context DeepinScreenshot_dde-desktop_20200128124331

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions and please check out this if you are wondering why we auto close issues.

tormi commented 3 years ago

This should cover profiling mode as well: https://github.com/lando/lando/issues/2718#issuecomment-770769207

tormi commented 3 years ago

You can use lando xdebug profile now with this recipe: https://github.com/lando/lando/issues/1668#issuecomment-772829423.

Preen commented 3 years ago

@tormi does your recipe solve the log location as well?

tormi commented 3 years ago

@Preen , what about the log location? You can define a custom xdebug.output_dir in the .lando/php.ini of my recipe https://github.com/lando/lando/issues/1668#issuecomment-772829423.

Preen commented 3 years ago

Yeah sorry, that solved it. Thanks for a great recipe! :)

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions and please check out this if you are wondering why we auto close issues.

stale[bot] commented 1 year ago

We haven't heard anything here for about a year so we are automatically closing this issue to keep things tidy. If this is in error then please post in this thread and request the issue be reopened!