Merge pull request 'Add the excimer profier injactable file' (#148) from profile-excimer into config

Reviewed-on: https://git.leftypol.org/leftypol/leftypol/pulls/148
This commit is contained in:
Zankaria 2024-06-21 21:05:27 +00:00
commit 466d569d74
2 changed files with 23 additions and 0 deletions

View file

@ -47,10 +47,12 @@ RUN apk add --no-cache \
&& pecl install -o -f igbinary \ && pecl install -o -f igbinary \
&& pecl install redis \ && pecl install redis \
&& pecl install imagick \ && pecl install imagick \
&& pecl install excimer \
&& docker-php-ext-enable \ && docker-php-ext-enable \
igbinary \ igbinary \
redis \ redis \
imagick \ imagick \
excimer \
&& apk del \ && apk del \
zlib-dev \ zlib-dev \
libpng-dev \ libpng-dev \

21
inc/profile.php Normal file
View file

@ -0,0 +1,21 @@
<?php
// From https://www.mediawiki.org/wiki/Excimer
// Inject with `auto_prepend_file` in php.ini
if (extension_loaded("excimer")) {
error_log("Profiler started", 0);
static $prof; // Keep object until the end of the request
$prof = new ExcimerProfiler();
$prof->setEventType(EXCIMER_REAL);
$prof->setPeriod(5); // every N seconds
$prof->setMaxDepth(250);
$prof->setFlushCallback(function ($log) {
error_log("Logged profile", 0);
file_put_contents('/tmp/profles-ramfs/excimer-traces.log', $log->formatCollapsed(), FILE_APPEND | LOCK_EX);
}, 1);
$prof->start();
} else {
error_log("Profiler code injected, but no excimer extension installed");
}