Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Finishes garbage collection before restarting the FrankenPHP worker process #897

Merged
merged 2 commits into from
May 24, 2024

Conversation

AlliBalliBaba
Copy link
Contributor

I noticed random server crashes when the FrankenPHP worker gracefully restarts. Usually php artisan octane:start will just exit with code 139.

This merge request mitigates these crashes by triggering garbage collection before restarting the server.

FrankenPHP generally recommends in its docs to trigger garbage collection after each request. I don't know if this is necessary, it slows down workers on simple request by ~10% in my tests.

What seems to be necessary though is finishing garbage collection before restarting the FrankenPHP process, otherwise memory can potentially be reused before it is freed by the GC (at least that's what I think happens). This will also not slow down the worker process.

might also be related.

@taylorotwell
Copy link
Member

Does this actually fix your issue?

@dunglas
Copy link
Contributor

dunglas commented May 23, 2024

I don't know if this patch fully fixes the issue, and the bug must be fixed in PHP itself too, but in the meantime we can merge it because at least it cannot cause any harm.

@dunglas
Copy link
Contributor

dunglas commented May 23, 2024

Regarding garbage collection after each request, the rationale is to prevent the GC to be triggered in the middle of a request. But maybe should we do that after N requests or make the value configurable.

@driesvints driesvints changed the title Finishes garbage collection before restarting the FrankenPHP worker process. Finishes garbage collection before restarting the FrankenPHP worker process May 24, 2024
@taylorotwell taylorotwell merged commit e0ab5c8 into laravel:2.x May 24, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants