Skip to content
This repository was archived by the owner on Dec 19, 2019. It is now read-only.

Commit 88e7a87

Browse files
Static Content Deploy - Decrease time waste on sleep()
Issue #1: Static content deploy waits 3 sec in single-job mode after finish Fixed by moving this sleep() into if ($this->isCanBeParalleled()) { ... } Issue #2: Static content deploy has 5 secs delay between checking if worker job finished processing. It leads up to 5 sec time waste before next job will start. Improved by decreasing time from 5 sec to 0.5 sec with saving log refresh rate (10*0.5 sec) On 4 themes and 7 locales these fixes improve time of static content deploy by 10-15 secs
1 parent db0dce6 commit 88e7a87

File tree

1 file changed

+31
-8
lines changed

1 file changed

+31
-8
lines changed

app/code/Magento/Deploy/Process/Queue.php

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -161,19 +161,32 @@ public function getPackages()
161161
public function process()
162162
{
163163
$returnStatus = 0;
164+
$logDelay = 10;
164165
$this->start = $this->lastJobStarted = time();
165166
$packages = $this->packages;
166167
while (count($packages) && $this->checkTimeout()) {
167168
foreach ($packages as $name => $packageJob) {
168169
// Unsets each member of $packages array (passed by reference) as each is executed
169170
$this->assertAndExecute($name, $packages, $packageJob);
170171
}
171-
$this->logger->info('.');
172-
// phpcs:ignore Magento2.Functions.DiscouragedFunction
173-
sleep(3);
174-
foreach ($this->inProgress as $name => $package) {
175-
if ($this->isDeployed($package)) {
176-
unset($this->inProgress[$name]);
172+
173+
// refresh current status in console once in 10 iterations (once in 5 sec)
174+
if ($logDelay >= 10) {
175+
$this->logger->info('.');
176+
$logDelay = 0;
177+
} else {
178+
$logDelay++;
179+
}
180+
181+
if ($this->isCanBeParalleled()) {
182+
// in parallel mode sleep before trying to check status and run new jobs
183+
// phpcs:ignore Magento2.Functions.DiscouragedFunction
184+
usleep(500000); // 0.5 sec (less sleep == less time waste)
185+
186+
foreach ($this->inProgress as $name => $package) {
187+
if ($this->isDeployed($package)) {
188+
unset($this->inProgress[$name]);
189+
}
177190
}
178191
}
179192
}
@@ -243,15 +256,25 @@ private function executePackage(Package $package, string $name, array &$packages
243256
*/
244257
private function awaitForAllProcesses()
245258
{
259+
$logDelay = 10;
246260
while ($this->inProgress && $this->checkTimeout()) {
247261
foreach ($this->inProgress as $name => $package) {
248262
if ($this->isDeployed($package)) {
249263
unset($this->inProgress[$name]);
250264
}
251265
}
252-
$this->logger->info('.');
266+
267+
// refresh current status in console once in 10 iterations (once in 5 sec)
268+
if ($logDelay >= 10) {
269+
$this->logger->info('.');
270+
$logDelay = 0;
271+
} else {
272+
$logDelay++;
273+
}
274+
275+
// sleep before checking parallel jobs status
253276
// phpcs:ignore Magento2.Functions.DiscouragedFunction
254-
sleep(5);
277+
usleep(500000); // 0.5 sec (less sleep == less time waste)
255278
}
256279
if ($this->isCanBeParalleled()) {
257280
// close connections only if ran with forks

0 commit comments

Comments
 (0)