Merge pull request #11345 from appwrite/perf/mem-usage

Load static files before Swoole fork for CoW memory sharing
This commit is contained in:
Luke B. Silver authored and GitHub committed 2026-02-17 12:18:07 +00:00
commit 6a08dcba1a
1 file changed
+5 -8
+5 -8
View File
@@ -37,7 +37,8 @@ use Utopia\System\System;
const DOMAIN_SYNC_TIMER = 30; // 30 seconds
$files = null;
$files = new Files();
$files->load(__DIR__ . '/../public');
$domains = new Table(1_000_000); // 1 million rows
$domains->column('value', Table::TYPE_INT, 1);
@@ -164,11 +165,7 @@ $http
Constant::OPTION_TASK_WORKER_NUM => 1, // required for the task to fetch domains background
]);
$http->on(Constant::EVENT_WORKER_START, function ($server, $workerId) use (&$files) {
if (!$server->taskworker) {
$files = new Files();
$files->load(__DIR__ . '/../public');
}
$http->on(Constant::EVENT_WORKER_START, function ($server, $workerId) {
});
$http->on(Constant::EVENT_WORKER_STOP, function ($server, $workerId) {
@@ -452,7 +449,7 @@ $http->on(Constant::EVENT_START, function (Server $http) use ($payloadSize, $tot
});
});
$http->on(Constant::EVENT_REQUEST, function (SwooleRequest $swooleRequest, SwooleResponse $swooleResponse) use ($register, &$files) {
$http->on(Constant::EVENT_REQUEST, function (SwooleRequest $swooleRequest, SwooleResponse $swooleResponse) use ($register, $files) {
Span::init('http.request');
Http::setResource('swooleRequest', fn () => $swooleRequest);
@@ -463,7 +460,7 @@ $http->on(Constant::EVENT_REQUEST, function (SwooleRequest $swooleRequest, Swool
Span::add('http.method', $request->getMethod());
if ($files instanceof Files && $files->isFileLoaded($request->getURI())) {
if ($files->isFileLoaded($request->getURI())) {
$time = (60 * 60 * 24 * 45); // 45 days cache
$response