-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
perf: Log excessive memory usage on normal requests #49913
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
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: Joas Schilling <coding@schilljs.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good
$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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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:
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah fair enough
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea.
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