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

fix(dav): Reduce CalDAV backend memory footprint #40665

Merged
merged 1 commit into from
Nov 2, 2023

Conversation

ChristophWurst
Copy link
Member

@ChristophWurst ChristophWurst commented Sep 27, 2023

Summary

fetchAll inflates memory. Fetching in a loop allows GC to run earlier and more often.

TODO

  • Replace memory-hungry fetchAll

Checklist

@ChristophWurst
Copy link
Member Author

/backport to stable26

@ChristophWurst
Copy link
Member Author

/backport to stable27

@@ -2656,9 +2661,9 @@ public function getSchedulingObjects($principalUri) {
->where($query->expr()->eq('principaluri', $query->createNamedParameter($principalUri)))
->executeQuery();

$result = [];
foreach ($stmt->fetchAll() as $row) {
Copy link
Member Author

Choose a reason for hiding this comment

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

from prod:

{
  "reqId": "abc123",
  "level": 3,
  "time": "2023-10-06T06:25:16+00:00",
  "remoteAddr": "aaa:bbb:ccc::",
  "user": "user123",
  "app": "PHP",
  "method": "REPORT",
  "url": "/remote.php/dav/calendars/user123/inbox/",
  "message": "Allowed memory size of 536870912 bytes exhausted (tried to allocate 135168 bytes) at /var/www/nextcloud/apps/dav/lib/CalDAV/CalDavBackend.php#2661",
  "userAgent": "iOS/17.0.3 (21A360) dataaccessd/1.0",
  "version": "27.1.2.1",
  "data": {
    "app": "PHP"
  },
  "id": "651faa6e0d5c0"
}

Copy link
Member Author

Choose a reason for hiding this comment

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

yet this probably means memory was almost full before. those 135168 are just the tip of the iceberg.

Copy link
Member

@blizzz blizzz Oct 6, 2023

Choose a reason for hiding this comment

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

all the array_(map|filter|…) functions are also quite memory heavy – good to have them resolved.

@solracsf solracsf added this to the Nextcloud 28 milestone Oct 27, 2023
@skjnldsv skjnldsv mentioned this pull request Nov 1, 2023
fetchAll inflates memory. Fetching in a loop allows GC to run earlier
and more often.

Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
@ChristophWurst ChristophWurst force-pushed the fix/dav/caldav-backend-memory-footprint branch from 9daf8b2 to 91b31bf Compare November 2, 2023 10:13
Copy link
Contributor

@kesselb kesselb left a comment

Choose a reason for hiding this comment

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

🏎️

@ChristophWurst ChristophWurst merged commit 9e56408 into master Nov 2, 2023
49 checks passed
@ChristophWurst ChristophWurst deleted the fix/dav/caldav-backend-memory-footprint branch November 2, 2023 13:56
@ChristophWurst
Copy link
Member Author

/backport to stable27

@ChristophWurst
Copy link
Member Author

It's there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review Waiting for reviews bug
Projects
Development

Successfully merging this pull request may close these issues.

5 participants