It seems that in the rewrite for Drupal 8, the ability to profile drush commands (which used to be enabled whenever xhprof_enable was true) is no longer present. I can profile page requests on the site without a problem, but if I run a drush command, the run is not profiled/available in XHProf afterwards.

I'm specifically asking since I like to be able to profile Migrate commands through Drush using XHProf, and it seems difficult to do this in Drupal 8.

#2 profile_drush_cli_with-2765651-2.patch545 byteshumansky
Members fund testing for the Drupal project. Drupal Association Learn more


geerlingguy created an issue. See original summary.

humansky’s picture

I ran into a similar issue with the 7.x version as well. I found that the problem is with drush and the way it uses a separate tmp directory from the rendered pages on my hosting provider (Acquia). If xhprof.output_dir is not set, then drush defaults to "/tmp" only. However, for rendered pages, it first checks xhprof.output_dir, if that's not set, then it checks sys_get_temp_dir() to see if it returns a result (which is does on Acquia, /mnt/tmp/[site].[env]), only when the above two conditions fails, it then sets the output_dir value to "/tmp".

Long term strategy might be to combine the two classes and create a common base class that utilizes a lot of the same variables, members, and instances. For now, I attached a simple patch that fixes the D7 version of this module. Perhaps someone with better D8 experience can create a a 8.x version of the patch as well, otherwise I will also give it a shot.

humansky’s picture

Status: Active » Needs work
Issue tags: +Needs backport to 8.x-1.x
humansky’s picture

Status: Needs work » Needs review

Sorry, meant to change the status to "Needs Review"

andypost’s picture

Status: Needs review » Needs work
andypost’s picture