Skip to content

Commit 4dd7b97

Browse files
committed
MAGETWO-93319: Parallelization update
1 parent dfcf068 commit 4dd7b97

File tree

1 file changed

+4
-31
lines changed

1 file changed

+4
-31
lines changed

app/code/Magento/Indexer/Model/ProcessManager.php

Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -15,47 +15,36 @@ class ProcessManager
1515
*/
1616
const THREADS_COUNT = 'MAGE_INDEXER_THREADS_COUNT';
1717

18-
/**
19-
* Configuration path for threads count
20-
*/
21-
const THREADS_COUNT_CONFIG_PATH = 'indexer/threads_count';
22-
2318
/** @var bool */
2419
private $failInChildProcess = false;
2520

2621
/** @var \Magento\Framework\App\ResourceConnection */
2722
private $resource;
2823

29-
/** @var \Magento\Framework\App\DeploymentConfig */
30-
private $deploymentConfig;
31-
3224
/** @var \Magento\Framework\Registry */
3325
private $registry;
3426

3527
/** @var int|null */
36-
private $threadsCountFromEnvVariable;
28+
private $threadsCount;
3729

3830
/**
3931
* @param \Magento\Framework\App\ResourceConnection $resource
40-
* @param \Magento\Framework\App\DeploymentConfig $deploymentConfig
4132
* @param \Magento\Framework\Registry $registry
4233
* @param int|null $threadsCount
4334
*/
4435
public function __construct(
4536
\Magento\Framework\App\ResourceConnection $resource,
46-
\Magento\Framework\App\DeploymentConfig $deploymentConfig,
4737
\Magento\Framework\Registry $registry = null,
4838
int $threadsCount = null
4939
) {
5040
$this->resource = $resource;
51-
$this->deploymentConfig = $deploymentConfig;
5241
if (null === $registry) {
5342
$registry = \Magento\Framework\App\ObjectManager::getInstance()->get(
5443
\Magento\Framework\Registry::class
5544
);
5645
}
5746
$this->registry = $registry;
58-
$this->threadsCountFromEnvVariable = $threadsCount;
47+
$this->threadsCount = $threadsCount;
5948
}
6049

6150
/**
@@ -65,7 +54,7 @@ public function __construct(
6554
*/
6655
public function execute($userFunctions)
6756
{
68-
if ($this->getThreadsCount() > 1 && $this->isCanBeParalleled() && !$this->isSetupMode() && PHP_SAPI == 'cli') {
57+
if ($this->threadsCount > 1 && $this->isCanBeParalleled() && !$this->isSetupMode() && PHP_SAPI == 'cli') {
6958
$this->multiThreadsExecute($userFunctions);
7059
} else {
7160
$this->simpleThreadExecute($userFunctions);
@@ -123,22 +112,6 @@ private function isCanBeParalleled()
123112
return function_exists('pcntl_fork');
124113
}
125114

126-
/**
127-
* Get threads count
128-
*
129-
* @return bool
130-
*/
131-
private function getThreadsCount()
132-
{
133-
if ($this->threadsCountFromEnvVariable !== null) {
134-
return (int)$this->threadsCountFromEnvVariable;
135-
}
136-
if ($this->deploymentConfig->get(self::THREADS_COUNT_CONFIG_PATH) !== null) {
137-
return (int)$this->deploymentConfig->get(self::THREADS_COUNT_CONFIG_PATH);
138-
}
139-
return 1;
140-
}
141-
142115
/**
143116
* Is setup mode
144117
*
@@ -170,7 +143,7 @@ private function startChildProcess($userFunction)
170143
private function executeParentProcess(&$threadNumber)
171144
{
172145
$threadNumber++;
173-
if ($threadNumber >= $this->getThreadsCount()) {
146+
if ($threadNumber >= $this->threadsCount) {
174147
pcntl_wait($status);
175148
if (pcntl_wexitstatus($status) !== 0) {
176149
$this->failInChildProcess = true;

0 commit comments

Comments
 (0)