Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added PULL_REQUEST.md
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
}

Expand Down
6 changes: 4 additions & 2 deletions src/Phaseolies/Http/Controllers/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Expand Down
Loading