-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/develop' into MAGETWO-44448-va…
…rnish-bottle-neck
- Loading branch information
Showing
19 changed files
with
430 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
app/code/Magento/Catalog/Model/ResourceModel/MaxHeapTableSizeProcessor.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<?php | ||
/** | ||
* Copyright © 2015 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\Catalog\Model\ResourceModel; | ||
|
||
use Magento\Framework\App\ResourceConnection; | ||
|
||
class MaxHeapTableSizeProcessor | ||
{ | ||
/** | ||
* Database connection adapter | ||
* | ||
* @var \Magento\Framework\DB\Adapter\AdapterInterface | ||
*/ | ||
protected $connection; | ||
|
||
/** | ||
* @var int | ||
*/ | ||
protected $defaultMaxHeapTableSie; | ||
|
||
/** | ||
* Current max_heap_table_size value (in Bytes) | ||
* | ||
* @var int | ||
*/ | ||
protected $currentMaxHeapTableSize = null; | ||
|
||
/** | ||
* @param ResourceConnection $resource | ||
*/ | ||
public function __construct(ResourceConnection $resource) | ||
{ | ||
$this->connection = $resource->getConnection(); | ||
$this->defaultMaxHeapTableSie = 1024 * 1024 * 64; | ||
} | ||
|
||
/** | ||
* Set max_heap_table_size value in Bytes. By default value is 64M | ||
* | ||
* @param int|null $maxHeapTableSize | ||
* @throws \InvalidArgumentException | ||
* @throws \RuntimeException | ||
* @return void | ||
*/ | ||
public function set($maxHeapTableSize = null) | ||
{ | ||
$maxHeapTableSize = (int) (null === $maxHeapTableSize ? $this->defaultMaxHeapTableSie : $maxHeapTableSize); | ||
if (!$maxHeapTableSize) { | ||
throw new \InvalidArgumentException('Wrong max_heap_table_size parameter'); | ||
} | ||
|
||
$this->currentMaxHeapTableSize = (int)$this->connection->fetchOne('SELECT @@session.max_heap_table_size'); | ||
if (!$this->currentMaxHeapTableSize) { | ||
throw new \RuntimeException('Can not extract max_heap_table_size'); | ||
} | ||
|
||
$this->connection->query('SET SESSION max_heap_table_size = ' . $maxHeapTableSize); | ||
} | ||
|
||
/** | ||
* Restore max_heap_table_size value | ||
* | ||
* @throws \RuntimeException | ||
* @return void | ||
*/ | ||
public function restore() | ||
{ | ||
if (null === $this->currentMaxHeapTableSize) { | ||
throw new \RuntimeException('max_heap_table_size parameter is not set'); | ||
} | ||
$this->connection->query('SET SESSION max_heap_table_size = ' . $this->currentMaxHeapTableSize); | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
.../Catalog/Plugin/Model/Indexer/Category/Product/MaxHeapTableSizeProcessorOnFullReindex.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
/** | ||
* Copyright © 2015 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
namespace Magento\Catalog\Plugin\Model\Indexer\Category\Product; | ||
|
||
use Magento\Catalog\Model\Indexer\Category\Product\Action\Full; | ||
use Magento\Catalog\Model\ResourceModel\MaxHeapTableSizeProcessor; | ||
use Psr\Log\LoggerInterface; | ||
|
||
class MaxHeapTableSizeProcessorOnFullReindex | ||
{ | ||
/** | ||
* @var MaxHeapTableSizeProcessor | ||
*/ | ||
protected $maxHeapTableSizeProcessor; | ||
|
||
/** | ||
* @param MaxHeapTableSizeProcessor $maxHeapTableSizeProcessor | ||
* @param LoggerInterface $logger | ||
*/ | ||
public function __construct( | ||
MaxHeapTableSizeProcessor $maxHeapTableSizeProcessor, | ||
LoggerInterface $logger | ||
) { | ||
$this->maxHeapTableSizeProcessor = $maxHeapTableSizeProcessor; | ||
$this->logger = $logger; | ||
} | ||
|
||
/** | ||
* @param Full $subject | ||
* @return void | ||
* @SuppressWarnings(PHPMD.UnusedFormalParameter) | ||
*/ | ||
public function beforeExecute(Full $subject) | ||
{ | ||
try { | ||
$this->maxHeapTableSizeProcessor->set(); | ||
} catch (\Exception $e) { | ||
$this->logger->error($e); | ||
} | ||
} | ||
|
||
/** | ||
* @param Full $subject | ||
* @param Full $result | ||
* @return Full | ||
* @SuppressWarnings(PHPMD.UnusedFormalParameter) | ||
*/ | ||
public function afterExecute(Full $subject, Full $result) | ||
{ | ||
try { | ||
$this->maxHeapTableSizeProcessor->restore(); | ||
} catch (\Exception $e) { | ||
$this->logger->error($e); | ||
} | ||
return $result; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
email,_website,_store,confirmation,created_at,created_in,disable_auto_group_change,dob,firstname,gender,group_id,lastname,middlename,password_hash,prefix,reward_update_notification,reward_warning_notification,rp_token,rp_token_created_at,store_id,suffix,taxvat,updated_at,website_id,password | ||
jondoe@example.com,base,default,,"2015-10-30 12:49:47","Default Store View",0,,Jon,,1,Doe,,d708be3fe0fe0120840e8b13c8faae97424252c6374227ff59c05814f1aecd79:mgLqkqgTwLPLlCljzvF8hp67fNOOvOZb:1,,,,07e71459c137f4da15292134ff459cba,"2015-10-30 12:49:48",1,,,"2015-10-30 12:49:48",1, |
2 changes: 2 additions & 0 deletions
2
app/code/Magento/ImportExport/Files/Sample/customer_address.csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
_website,_email,_entity_id,city,company,country_id,fax,firstname,lastname,middlename,postcode,prefix,region,region_id,street,suffix,telephone,vat_id,vat_is_valid,vat_request_date,vat_request_id,vat_request_success,_address_default_billing_,_address_default_shipping_ | ||
base,jondoe@example.com,1,"New York",,US,,Jon,Doe,,10044,,"New York",43,"Main Street 1",,123456789,,,,,,1,1 |
2 changes: 2 additions & 0 deletions
2
app/code/Magento/ImportExport/Files/Sample/customer_finance.csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
_email,_website,_finance_website,store_credit,reward_points | ||
jondoe@example.com,base,base,10.0000,100 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.