Building `gd` ext takes 37x more time since PHP 8.1
This is a performance issue of php-src build.
see https://github.com/mvorisek/image-php/runs/5194149719 and https://github.com/mvorisek/image-php/runs/5194149745
PHP 8.1 build takes +- twice as long on Alpine & Debian platforms
results are repeatable across CI history
source DockerFiles are available at https://github.com/mvorisek/image-php/tree/master/data, all images are build with the same config and php extensions, thus I would expect the same build time
I have written a script to analyse the raw CI files from Github Actions build:
<?php
class File {
public $p;
public $content;
public $lines;
public function __construct(string $p) {
$this->p = $p;
$this->content = file_get_contents($this->p);
$this->lines = $this->parseLines($this->content);
}
protected function parseLines(string $content): array {
$lines = [];
$tsPrev = null;
$tsFracPrev = null;
foreach (explode("\n", trim($content)) as $rawLine) {
$rawLineParts = explode(' ', $rawLine, 2);
$timeParts = explode('.', $rawLineParts[0], 2);
$ts = \DateTime::createFromFormat('!Y-m-d\TH:i:s', $timeParts[0], new \DateTimeZone('UTC'));
$tsFrac = rtrim($timeParts[1], 'Z');
$tsDiff = $tsPrev === null ? 0.0 : ($ts->getTimestamp() - $tsPrev->getTimestamp()) + ($tsFrac - $tsFracPrev) * 1e-7;
$tsPrev = $ts;
$tsFracPrev = $tsFrac;
$lines[] = [$tsDiff, $rawLineParts[1]];
}
return $lines;
}
public function findSlowLines(): array {
$res = [];
$prevLines = [];
$addPrevToRes = function () use (&$res, &$prevLines) {
$t = 0.0;
$str = '';
foreach ($prevLines as $lineArr) {
$t += $lineArr[0];
$str .= ($str === '' ? '' : ' ') . $lineArr[1];
}
$prevLines = [];
$res[] = [$t, $str];
};
foreach ($this->lines as $lineArr) {
// split by major actions or slow operations
if (preg_match('~^Step \d+/\d+ : |^###~', $lineArr[1])/* || $lineArr[0] > 0.5*/) {
$addPrevToRes();
}
$prevLines[] = $lineArr;
}
$addPrevToRes();
return $res;
}
public function slowLinesToFile(string $p): void {
$slowLines = $this->findSlowLines();
$resLines = [];
foreach ($slowLines as $slowLineArr) {
$resLines[] = number_format($slowLineArr[0], 7) . "\t" . substr($slowLineArr[1], 0, 500);
}
file_put_contents($p, implode("\n", $resLines));
}
}
$f80 = new File(__DIR__ . '/80.txt');
$f81 = new File(__DIR__ . '/81.txt');
print_r($f80->findSlowLines());
$f80->slowLinesToFile(__DIR__ . '/80-parsed.txt');
$f81->slowLinesToFile(__DIR__ . '/81-parsed.txt');
and discovered, the gd build is superslow:

PHP 8.0 build time: 12.5 s, PHP 8.1 476.3 s
full build outputs of gd ext with elapsed times:
https://pastebin.com/L1qvS2F1 PHP 8.0 https://pastebin.com/hnf1eMm1 PHP 8.1

Building libavif and dependencies probably takes a while, which is new in 8.1, you may try building with IPE_GD_WITHOUTAVIF=1
Not a php-src problem.
current lts and stable versions of the used distributions lack codec for libavif. Maintainers can't fix that but in the next minor upgrades.
On Sat, Feb 19, 2022, 10:31 PM Nikita Popov @.***> wrote:
Closed #8118 https://github.com/php/php-src/issues/8118.
— Reply to this email directly, view it on GitHub https://github.com/php/php-src/issues/8118#event-6106058899, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACE6KH7FM4XJVHIGZPQPM3U36ZWPANCNFSM5OXZP2RQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
You are receiving this because you are subscribed to this thread.Message ID: @.***>