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

perf: Log excessive memory usage on normal requests #49913

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

nickvergessen
Copy link
Member

  • Resolves: #

Summary

TODO

  • ...

Checklist

Copy link
Member

@ChristophWurst ChristophWurst left a 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);
Copy link
Member

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);
Copy link
Member

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?

Copy link
Member Author

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: ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah fair enough

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.

2 participants