perf: Log excessive memory usage on normal requests#49913
perf: Log excessive memory usage on normal requests#49913nickvergessen wants to merge 1 commit intomasterfrom
Conversation
Signed-off-by: Joas Schilling <coding@schilljs.com>
| $memoryAfter = memory_get_usage(); | ||
| if ($memoryAfter - $memoryBefore > 400_000_000) { | ||
| $message = 'Used memory was more than 400 MB: ' . \OCP\Util::humanFileSize($memoryAfter - $memoryBefore); | ||
| \OCP\Server::get(LoggerInterface::class)->warning($message); |
There was a problem hiding this comment.
nit: use the OCP\Log\logger function because it includes error handling when the loggerinterface can't be resolved
| } finally { | ||
| $memoryAfter = memory_get_usage(); | ||
| if ($memoryAfter - $memoryBefore > 400_000_000) { | ||
| $message = 'Used memory was more than 400 MB: ' . \OCP\Util::humanFileSize($memoryAfter - $memoryBefore); |
There was a problem hiding this comment.
learning from my own pr #45804 is to not encode the threshold in the log message as it makes grepping harder 😬
How about we log Excessive memory used or similar and put the threshold into the context object of the log?
There was a problem hiding this comment.
But then we don't see it right away in lnav or any other tool. Since it's at the end you can already grep for Used memory was more than 400 MB: ?
|
My brain doesn't want to accept the |
|
Well the problem is that lib/base.php is only doing the autoloading, so it has to be before the |
Summary
TODO
Checklist