From 5e70eda5d36272e518feb7afceaa03fc38e9dc07 Mon Sep 17 00:00:00 2001 From: Arif Hoque Date: Wed, 25 Mar 2026 21:01:52 +0600 Subject: [PATCH] critical performance bottlenecks --- PULL_REQUEST.md | 0 .../Entity/Query/InteractsWithBigDataProcessing.php | 4 ---- src/Phaseolies/Http/Controllers/Controller.php | 6 ++++-- 3 files changed, 4 insertions(+), 6 deletions(-) create mode 100644 PULL_REQUEST.md diff --git a/PULL_REQUEST.md b/PULL_REQUEST.md new file mode 100644 index 00000000..e69de29b diff --git a/src/Phaseolies/Database/Entity/Query/InteractsWithBigDataProcessing.php b/src/Phaseolies/Database/Entity/Query/InteractsWithBigDataProcessing.php index 29341c16..8a6fb338 100644 --- a/src/Phaseolies/Database/Entity/Query/InteractsWithBigDataProcessing.php +++ b/src/Phaseolies/Database/Entity/Query/InteractsWithBigDataProcessing.php @@ -38,11 +38,7 @@ public function chunk($chunkSize, callable $processor, ?int $total = null): void $offset += $chunkSize; // prevent memory leaks - // unsetting and invoking garbage collection unset($chunkQuery, $results); - if (gc_enabled()) { - gc_collect_cycles(); - } } } diff --git a/src/Phaseolies/Http/Controllers/Controller.php b/src/Phaseolies/Http/Controllers/Controller.php index 9de3bf6e..90ae5f4d 100644 --- a/src/Phaseolies/Http/Controllers/Controller.php +++ b/src/Phaseolies/Http/Controllers/Controller.php @@ -487,9 +487,11 @@ protected function compileAndCache(string $actual, string $cache): void @unlink($tempFile); } - // Small delay before retry to avoid race conditions + // Exponential backoff with jitter to prevent thundering herd if ($retries < self::MAX_COMPILE_RETRIES) { - usleep(10000 * $retries); // 10ms, 20ms, 30ms + $baseDelay = 10000 * (2 ** ($retries - 1)); // 10ms, 20ms, 40ms, 80ms + $jitter = random_int(0, $baseDelay / 4); // ±25% jitter + usleep($baseDelay + $jitter); } } }