diff --git a/PULL_REQUEST.md b/PULL_REQUEST.md new file mode 100644 index 0000000..e69de29 diff --git a/src/Phaseolies/Database/Entity/Query/InteractsWithBigDataProcessing.php b/src/Phaseolies/Database/Entity/Query/InteractsWithBigDataProcessing.php index 29341c1..8a6fb33 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 9de3bf6..90ae5f4 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); } } }