Skip to content

Conversation

nickvergessen
Copy link
Member

  • Resolves: #

Summary

TODO

  • ...

Checklist

Signed-off-by: Joas Schilling <coding@schilljs.com>
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

Copy link
Member

@joshtrichards joshtrichards left a comment

Choose a reason for hiding this comment

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

Good idea.

@joshtrichards
Copy link
Member

My brain doesn't want to accept the memory_get_usage() call being above the use statements. It just feels wrong.

@nickvergessen
Copy link
Member Author

Well the problem is that lib/base.php is only doing the autoloading, so it has to be before the use calls, but it also does the init already and sets up some apps and things, so we want to measure it as well

@blizzz blizzz mentioned this pull request Jan 8, 2025
This was referenced Jan 14, 2025
This was referenced Jan 21, 2025
@blizzz blizzz mentioned this pull request Jan 29, 2025
1 task
@blizzz blizzz modified the milestones: Nextcloud 31, Nextcloud 32 Jan 29, 2025
This was referenced Aug 22, 2025
This was referenced Sep 2, 2025
This was referenced Sep 25, 2025
@skjnldsv skjnldsv modified the milestones: Nextcloud 32, Nextcloud 33 Sep 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants