Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[Debug][ErrorHandler] Increased the reserved memory from 10k to 32k#44327
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
[Debug][ErrorHandler] Increased the reserved memory from 10k to 32k#44327
Uh oh!
There was an error while loading.Please reload this page.
Conversation
The ErrorHandler's job includes handling out of memory (OOM) exceptions,therefore it is imoprtant that that feature works. In the current state,when handling OOM exceptions, the error handler produces an OOM erroritself, because the old 10k reserve is apparently not enough anymore.To mitigate that, the reserved memory gets bumped to 32k (which is enouogh).
carsonbot commentedNov 29, 2021
Hey! I see that this is your first PR. That is great! Welcome! Symfony has acontribution guide which I suggest you to read. In short:
Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change. When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor! I am going to sit back now and wait for the reviews. Cheers! Carsonbot |
fabpot commentedNov 29, 2021
Thank you@sakalys. |
* Increase reserved memory for error handlingFollow up to#42630The error handler should be able to report exceptionsarising from exceeding the PHP memory limit. Becauseof changes made to error handling, the previouslyconfigured value is no longer sufficiently large.A similar change was also done in Symfony a while ago,seesymfony/symfony#44327.I used the following artisan command to determine the amountof memory required for error handling, using a reporter thatsimply writes to a file:```php<?php declare(strict_types=1);namespace App\Console\Commands;use Illuminate\Console\Command;final class MeasureHandlerMemory extends Command{ protected $signature = 'measure-handler-memory'; private int $peak; public function handle(): void { $this->peak = memory_get_peak_usage(); trigger_error('', E_USER_ERROR); } public function __destruct() { $used = memory_get_peak_usage() - $this->peak; echo "error handling used: " . $used . "\n"; $before = memory_get_usage(); $times = 10240; $reserve = str_repeat('x', $times); $after = memory_get_usage() - $before; echo 'repeat times ' . $times . ' reserves: ' . $after . "\n"; $ratio = $after / $times; echo 'ratio between bytes and repeat: ' . $ratio . "\n"; echo 'minimum times to repeat: ' . $used / $ratio . "\n"; }}```* Free memory in HandleExceptions::handleShutdown()While validating the effectiveness of#42630in our application, I found that the call `$error = error_get_last()`causes a tiny bit of memory usage. Thus, I think it is betterto clear memory as soon as entering the handler.* Update HandleExceptions.phpCo-authored-by: Taylor Otwell <taylor@laravel.com>
* Increase reserved memory for error handlingFollow up tolaravel#42630The error handler should be able to report exceptionsarising from exceeding the PHP memory limit. Becauseof changes made to error handling, the previouslyconfigured value is no longer sufficiently large.A similar change was also done in Symfony a while ago,seesymfony/symfony#44327.I used the following artisan command to determine the amountof memory required for error handling, using a reporter thatsimply writes to a file:```php<?php declare(strict_types=1);namespace App\Console\Commands;use Illuminate\Console\Command;final class MeasureHandlerMemory extends Command{ protected $signature = 'measure-handler-memory'; private int $peak; public function handle(): void { $this->peak = memory_get_peak_usage(); trigger_error('', E_USER_ERROR); } public function __destruct() { $used = memory_get_peak_usage() - $this->peak; echo "error handling used: " . $used . "\n"; $before = memory_get_usage(); $times = 10240; $reserve = str_repeat('x', $times); $after = memory_get_usage() - $before; echo 'repeat times ' . $times . ' reserves: ' . $after . "\n"; $ratio = $after / $times; echo 'ratio between bytes and repeat: ' . $ratio . "\n"; echo 'minimum times to repeat: ' . $used / $ratio . "\n"; }}```* Free memory in HandleExceptions::handleShutdown()While validating the effectiveness oflaravel#42630in our application, I found that the call `$error = error_get_last()`causes a tiny bit of memory usage. Thus, I think it is betterto clear memory as soon as entering the handler.* Update HandleExceptions.phpCo-authored-by: Taylor Otwell <taylor@laravel.com>
Uh oh!
There was an error while loading.Please reload this page.
The ErrorHandler's job includes handling out of memory (OOM) exceptions,
therefore it is important that that feature works. In the current state,
when handling OOM exceptions, the error handler produces an OOM error
itself, because the old 10kB reserve is apparently not enough anymore.
To mitigate that, the reserved memory gets bumped to 32k (which is enough).
Note I'm not familiar with the whole open source submitting process, so any feedback and instructions on how to improve this PR are welcome.
I am not sure on how to write a unit test to test something like that (talking about the issue here#40824).