diff --git a/CHANGELOG.md b/CHANGELOG.md index 0270ef0..3c4782d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +### 1.15.3 (2021-08-26) + + * Added MySQL default settings check + * Added move_script_to_bottom check + * Removed merge and bundling checks since they often hurt performance + ### 1.15.2 (2021-07-23) * Fixed logger path diff --git a/Model/DashboardRow/MySQLSettings.php b/Model/DashboardRow/MySQLSettings.php new file mode 100644 index 0000000..6959cb6 --- /dev/null +++ b/Model/DashboardRow/MySQLSettings.php @@ -0,0 +1,94 @@ + + * @copyright 2019 MageHost BV (https://magehost.pro) + * @license https://opensource.org/licenses/MIT MIT License + * @link https://github.com/magehost/performance-dashboard + */ + +namespace MageHost\PerformanceDashboard\Model\DashboardRow; + +use MageHost\PerformanceDashboard\Model\DashboardRow; +use MageHost\PerformanceDashboard\Model\DashboardRowInterface; +use Magento\Framework\App\ResourceConnection; + +/** + * Class MySQLSettings + * + * Dashboard row to check MySQL configuration + * + * @category MageHost + * @package MageHost\PerformanceDashboard\Model\DashboardRow + * @author Jeroen Vermeulen + * @license https://opensource.org/licenses/MIT MIT License + * @link https://github.com/magehost/performance-dashboard + */ +class MySQLSettings extends DashboardRow implements DashboardRowInterface +{ + /** + * @var ResourceConnection + */ + private $resourceConnection; + + + /** + * @var int[] + */ + private $defaultValues + = [ + 'innodb_buffer_pool_size' => 134217728, + 'max_connections' => 150, + 'innodb_thread_concurrency' => 0, + ]; + + /** + * MySQLSettings constructor. + * + * @param ResourceConnection $resourceConnection + * @param array $data + */ + public function __construct( + ResourceConnection $resourceConnection, + array $data + ) { + $this->resourceConnection = $resourceConnection; + parent::__construct($data); + } + + /** + * Load Row, is called by DashboardRowFactory + */ + public function load() + { + /** @noinspection PhpUndefinedMethodInspection */ + $this->setTitle(__('MySQL Configuration')); + $this->buttons[] = '[devdocs-guides]/performance-best-practices/software.html' . + '#mysql'; + + $connection = $this->resourceConnection->getConnection(); + $info = ''; + foreach ($this->defaultValues as $key => $value) { + $currentValue = $connection->fetchRow('SHOW VARIABLES LIKE \'' . $key . '\''); + if ($currentValue['Value'] <= $value) { + $this->problems .= $key . ' lower than - or equal to the default value: ' + . $currentValue['Value']; + $this->actions .= 'Ask your hosting to tune ' . $key; + } + $info .= $key . ' = ' . $currentValue['Value'] . "\n"; + } + + if ($this->problems == '') { + $this->info = $info; + } + + $this->groupProcess(); + } +} diff --git a/Model/ResourceModel/Grid/Collection.php b/Model/ResourceModel/Grid/Collection.php index 366feaa..974ced7 100644 --- a/Model/ResourceModel/Grid/Collection.php +++ b/Model/ResourceModel/Grid/Collection.php @@ -1,4 +1,5 @@ logger->debug( sprintf( "%s::%s does not get its data from direct database queries," . - "it is gathered from several internal Magento objects and logging.", + "it is gathered from several internal Magento objects and logging.", __CLASS__, __FUNCTION__ ) @@ -104,6 +105,8 @@ public function loadData($printQuery = false, $logQuery = false) /** @noinspection PhpUnhandledExceptionInspection */ $this->addItem($this->rowFactory->create('PhpSettings')); /** @noinspection PhpUnhandledExceptionInspection */ + $this->addItem($this->rowFactory->create('MySQLSettings')); + /** @noinspection PhpUnhandledExceptionInspection */ $this->addItem($this->rowFactory->create('AppStateMode')); /** @noinspection PhpUnhandledExceptionInspection */ $this->addItem($this->rowFactory->create('HttpVersion')); @@ -131,21 +134,20 @@ private function addItemsCache() $this->rowFactory->create( 'CacheStorage', [ - 'identifier' => 'default', - 'name' => 'Magento Cache', - 'buttons' => '[devdocs-guides]/config-guide/redis/redis-pg-cache.html' + 'identifier' => 'default', + 'name' => 'Magento Cache', + 'buttons' => '[devdocs-guides]/config-guide/redis/redis-pg-cache.html' ] ) ); - if (Config::BUILT_IN ==$this->scopeConfig->getValue('system/full_page_cache/caching_application') - ) { + if (Config::BUILT_IN == $this->scopeConfig->getValue('system/full_page_cache/caching_application')) { $this->addItem( $this->rowFactory->create( 'CacheStorage', [ - 'identifier' => 'page_cache', - 'name' => 'Full Page Cache', - 'buttons' => '[devdocs-guides]/config-guide/redis/redis-pg-cache.html' + 'identifier' => 'page_cache', + 'name' => 'Full Page Cache', + 'buttons' => '[devdocs-guides]/config-guide/redis/redis-pg-cache.html' ] ) ); @@ -206,11 +208,11 @@ private function addItemsConfig() $this->rowFactory->create( 'ConfigSetting', [ - 'title' => 'Full Page Caching Application', - 'path' => 'system/full_page_cache/caching_application', - 'recommended' => Config::VARNISH, - 'source' => \Magento\PageCache\Model\System\Config\Source\Application::class, - 'buttons' => '[devdocs-guides]/config-guide/varnish/config-varnish.html' + 'title' => 'Full Page Caching Application', + 'path' => 'system/full_page_cache/caching_application', + 'recommended' => Config::VARNISH, + 'source' => \Magento\PageCache\Model\System\Config\Source\Application::class, + 'buttons' => '[devdocs-guides]/config-guide/varnish/config-varnish.html' ] ) ); @@ -220,10 +222,10 @@ private function addItemsConfig() $this->rowFactory->create( 'ConfigSetting', [ - 'title' => 'Enable JavaScript Bundling', - 'path' => 'dev/js/enable_js_bundling', - 'recommended' => true, - 'buttons' => '[devdocs-guides]/frontend-dev-guide/themes/js-bundling.html' + 'title' => 'Enable JavaScript Bundling', + 'path' => 'dev/js/enable_js_bundling', + 'recommended' => true, + 'buttons' => '[devdocs-guides]/frontend-dev-guide/themes/js-bundling.html' ] ) ); @@ -231,11 +233,11 @@ private function addItemsConfig() $this->rowFactory->create( 'ConfigSetting', [ - 'title' => 'Merge JavaScript Files', - 'path' => 'dev/js/merge_files', - 'recommended' => true, - 'buttons' => '[devdocs-guides]/config-guide/prod/prod_perf-optimize.html'. - '#magento---performance-optimizations' + 'title' => 'Merge JavaScript Files', + 'path' => 'dev/js/merge_files', + 'recommended' => true, + 'buttons' => '[devdocs-guides]/config-guide/prod/prod_perf-optimize.html' . + '#magento---performance-optimizations' ] ) ); @@ -243,11 +245,11 @@ private function addItemsConfig() $this->rowFactory->create( 'ConfigSetting', [ - 'title' => 'Merge CSS Files', - 'path' => 'dev/css/merge_css_files', - 'recommended' => true, - 'buttons' => '[devdocs-guides]/config-guide/prod/prod_perf-optimize.html'. - '#magento---performance-optimizations' + 'title' => 'Merge CSS Files', + 'path' => 'dev/css/merge_css_files', + 'recommended' => true, + 'buttons' => '[devdocs-guides]/config-guide/prod/prod_perf-optimize.html' . + '#magento---performance-optimizations' ] ) ); @@ -256,11 +258,11 @@ private function addItemsConfig() $this->rowFactory->create( 'ConfigSetting', [ - 'title' => 'Minify JavaScript Files', - 'path' => 'dev/js/minify_files', - 'recommended' => true, - 'buttons' => '[devdocs-guides]/config-guide/prod/prod_perf-optimize.html'. - '#magento---performance-optimizations' + 'title' => 'Minify JavaScript Files', + 'path' => 'dev/js/minify_files', + 'recommended' => true, + 'buttons' => '[devdocs-guides]/config-guide/prod/prod_perf-optimize.html' . + '#magento---performance-optimizations' ] ) ); @@ -268,11 +270,11 @@ private function addItemsConfig() $this->rowFactory->create( 'ConfigSetting', [ - 'title' => 'Minify CSS Files', - 'path' => 'dev/css/minify_files', - 'recommended' => true, - 'buttons' => '[devdocs-guides]/config-guide/prod/prod_perf-optimize.html'. - '#magento---performance-optimizations' + 'title' => 'Minify CSS Files', + 'path' => 'dev/css/minify_files', + 'recommended' => true, + 'buttons' => '[devdocs-guides]/config-guide/prod/prod_perf-optimize.html' . + '#magento---performance-optimizations' ] ) ); @@ -280,11 +282,11 @@ private function addItemsConfig() $this->rowFactory->create( 'ConfigSetting', [ - 'title' => 'Minify HTML', - 'path' => 'dev/template/minify_html', - 'recommended' => true, - 'buttons' => '[devdocs-guides]/config-guide/prod/prod_perf-optimize.html'. - '#magento---performance-optimizations' + 'title' => 'Minify HTML', + 'path' => 'dev/template/minify_html', + 'recommended' => true, + 'buttons' => '[devdocs-guides]/config-guide/prod/prod_perf-optimize.html' . + '#magento---performance-optimizations' ] ) ); @@ -293,11 +295,11 @@ private function addItemsConfig() $this->rowFactory->create( 'ConfigSetting', [ - 'title' => 'Asynchronous sending of sales emails', - 'path' => 'sales_email/general/async_sending', - 'recommended' => true, - 'buttons' => '[user-guides]/configuration/sales/sales-emails.html'. - '#stores---configuration---sales---sales-emails' + 'title' => 'Asynchronous sending of sales emails', + 'path' => 'sales_email/general/async_sending', + 'recommended' => true, + 'buttons' => '[user-guides]/configuration/sales/sales-emails.html' . + '#stores---configuration---sales---sales-emails' ] ) ); diff --git a/README.md b/README.md index e1a0595..d3a7660 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,7 @@ Checks executed: * Is PHP 7 in use? * Is HTTP/2 in use? * Are the PHP performance settings correct? +* Are the MySQL performance settings tuned? * Is Magento in Production mode? * Is the Magento Cache stored in Redis? * Is the Full Page Cache stored in Redis? @@ -49,10 +50,10 @@ Checks executed: * Is the Full Page Cache using Varnish? * For Magento >= 2.3.1: * Is Elastic Search in use? +* For Magento >= 2.3.2: + * Is JavaScript defered? * For Magento < 2.2: * If not on HTTP/2: - * Is JavaScript bundling enabled? - * Is merging JavaScript files enabled? * Is merging CSS files enabled? * Is minify of JavaScript files enabled? * Is minify of CSS files enabled? diff --git a/composer.json b/composer.json index 25c7935..0bce524 100644 --- a/composer.json +++ b/composer.json @@ -3,7 +3,7 @@ "description": "Performance Dashboard for Magento 2.x by MageHost.pro", "homepage": "https://github.com/magehost/performance-dashboard", "type": "magento2-module", - "version": "1.15.2", + "version": "1.15.3", "minimum-stability": "beta", "license": "MIT", "authors":[