nextcloud / nextcloud/server

High memory consumption when getting address book cards

Open
#32,411 0 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

0. Needs triage feature: carddav performance 🚀 technical debt
Dominant language
PHP
Stars
36.9k
Forks
5.2k
Avg merge
2d 3h
Merged PRs (30d)
713

Description

Filing here as an issue to collect findings, I'm not entirely sure if that is something we really can solve properly e.g. by streaming the individual card data rather than keeping them all in memory.

There seems to be at least some additional overhead from https://github.com/nextcloud/server/pull/19901 but the major impact is the database result that is loaded.

https://blackfire.io/profiles/93136cfc-7b78-4919-b8ae-5695c0e905e2/graph?settings%5Bdimension%5D=pmu&settings%5Bdisplay%5D=landscape&settings%5BtabPane%5D=nodes&selected=OCA%5CDAV%5CCardDAV%5CCardDavBackend%3A%3AgetCards&callname=main()&constraintDoc=

Screenshot 2022-05-16 at 09 09 55

Some useful queries:

select id, sum(char_length(carddata)) from oc_cards where addressbookid = 7;
select id, char_length(carddata) as size from oc_cards where addressbookid = 7 order by size;
select substring_index(carddata, '\n', 10) from oc_cards where id = 3296;

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at CardDavBackend::getCards and use the linked Blackfire profile to inspect memory usage, then review the provided queries against oc_cards and carddata. Done would require a clearly demonstrated reduction in memory consumed while retrieving address book cards, with the existing card data still available to callers.

Written by the indexing model from the issue text.

Assessment

Tech stack
php, sql
Domain
backend, databases, performance
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.