hechoendrupal / drupal-console

The Drupal CLI. A tool to generate boilerplate code, interact with and debug Drupal.
http://drupalconsole.com
GNU General Public License v2.0
940 stars 559 forks source link

Bad performance #3149

Open Chi-teck opened 7 years ago

Chi-teck commented 7 years ago

I've installed the latest console version (1.0.0-rc15) and discovered that it works quite slow. On fresh site installation (Drupal v8.4.x, PHP 7.0) it takes about 2.5 seconds (!) to execute a simple command like site:status.

/var/www/d8/docroot[8.4.x]-> time drush st > /dev/null

real    0m1.081s
user    0m0.964s
sys 0m0.084s

/var/www/d8/docroot[8.4.x]-> time drupal ss > /dev/null

real    0m2.562s
user    0m2.204s
sys 0m0.268s

The benchmark above suggests that Drupal console spends at least 1.5 second on something not related to Drupal bootstrapping.

Note that this happens on any command executed in Drupal document root directory even drupal -v is very slow.

jmolivas commented 7 years ago

@Chi-teck thanks for reporting this is a known issue we like to address before the stable release. DO you know which tools we can use to detect why and where is this happening?

You can try drupal --debug so see which process is being executed

Alt text

Chi-teck commented 7 years ago

I walked through the code with xdebug and found that Drupal::boot() takes about 75 % of the request time. https://github.com/hechoendrupal/drupal-console/blob/master/bin/drupal.php#L49

I think it can be related to how service container is compiled and cached but am not certain.

I also noticed that the older Console version works quite well even a bit faster than Drush.

jmolivas commented 7 years ago

@Chi-teck I sent a PR https://github.com/hechoendrupal/drupal-console/pull/3155 to compile all of the YAML files where services are registered and create a single file.

As you can see the results the first execution is the one that takes longer because it creates the compiled-services file the rest of the executions only load one file to register console services.

drupal-list-time

I also found using vendor/bin/drupal instead of Launcher drupal is faster.

I will take a look to that project to improve the extra time added when finding the site.

hughworm commented 5 years ago

I have a similar problem only rather worse. On my dev machine console boot phase is taking >10s, mostly in the container rebuild. The site also takes this long to rebuild after clearing the cache. Any solution?