SUMMARY After a long time, I wanted to give Akonadi a new chance and installed it. After some time I noticed much worse gaming performance related to VRAM pressure. I've monitored nvidia-smi to see that my idle desktop now uses 3.8 GB of VRAM, with a lot of akonadi resource processes allocating 4 MB each from the driver directly but also the Xorg process was ballooned up to 2.7 GB of VRAM usage even after a fresh reboot. Usually, after reboot, Xorg would use around 800 MB of VRAM with some background processes having 4 MB allocated each, result in around 1.2 GB of VRAM usage for a freshly booted desktop, and up to 2.5 GB after some time of use (that's still a lot but a different concern). STEPS TO REPRODUCE 1. Install akonadi 2. Reboot 3. Observe nvidia-smi output after fresh boot and after some time of use OBSERVED RESULT Over 3 GB of VRAM usage after a fresh boot, increasing to almost 5 GB after some time of use. EXPECTED RESULT Stay below 2.5 GB of VRAM with some web browser windows open and Steam running. SOFTWARE/OS VERSIONS Operating System: Gentoo Linux 2.13 KDE Plasma Version: 5.27.4 KDE Frameworks Version: 5.105.0 Qt Version: 5.15.9 Kernel Version: 6.1.26-gentoo (64-bit) Graphics Platform: X11 Processors: 20 × 12th Gen Intel® Core™ i7-12700K Memory: 31.1 GiB of RAM Graphics Processor: NVIDIA GeForce RTX 3080 Ti/PCIe/SSE2 Manufacturer: ASRock Product Name: Z690 Pro RS # equery l nvidia-drivers * Searching for nvidia-drivers ... [IP-] [ ] x11-drivers/nvidia-drivers-525.116.03:0/525 ADDITIONAL INFORMATION Dual-monitor setup with "force full composition pipeline" enabled in nvidia-settings. nvidia-smi without akonadi running: Tue May 2 19:33:30 2023 +-----------------------------------------------------------------------------+ | NVIDIA-SMI 525.116.03 Driver Version: 525.116.03 CUDA Version: 12.0 | |-------------------------------+----------------------+----------------------+ | GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC | | Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. | | | | MIG M. | |===============================+======================+======================| | 0 NVIDIA GeForce ... Off | 00000000:01:00.0 On | N/A | | 0% 48C P5 46W / 370W | 2494MiB / 12288MiB | 30% Default | | | | N/A | +-------------------------------+----------------------+----------------------+ +-----------------------------------------------------------------------------+ | Processes: | | GPU GI CI PID Type Process name GPU Memory | | ID ID Usage | |=============================================================================| | 0 N/A N/A 1625 G /usr/libexec/Xorg 1734MiB | | 0 N/A N/A 2328 G /usr/bin/kwin_x11 149MiB | | 0 N/A N/A 2329 G /usr/bin/ksmserver 4MiB | | 0 N/A N/A 2331 G /usr/bin/kded5 4MiB | | 0 N/A N/A 2509 G /usr/bin/plasmashell 180MiB | | 0 N/A N/A 2570 G ...de-authentication-agent-1 4MiB | | 0 N/A N/A 2573 G ...ec/xdg-desktop-portal-kde 4MiB | | 0 N/A N/A 2680 G /usr/bin/python3.10 4MiB | | 0 N/A N/A 2684 G ...lib64/libexec/kdeconnectd 4MiB | | 0 N/A N/A 2685 G /usr/bin/kleopatra 4MiB | | 0 N/A N/A 2686 G /usr/bin/keepassxc 4MiB | | 0 N/A N/A 2698 G /usr/bin/kaccess 4MiB | | 0 N/A N/A 2702 G .../libexec/DiscoverNotifier 4MiB | | 0 N/A N/A 3942 G ...aw,WebRTCPipeWireCapturer 88MiB | | 0 N/A N/A 3945 G /usr/bin/kwalletd5 4MiB | | 0 N/A N/A 4159 G ...b64/libexec/kf5/klauncher 4MiB | | 0 N/A N/A 4301 G ...-browser-integration-host 4MiB | | 0 N/A N/A 6838 G ...veSuggestionsOnlyOnDemand 108MiB | | 0 N/A N/A 7318 G /usr/bin/krunner 13MiB | | 0 N/A N/A 7386 G ...lib64/libexec/baloorunner 4MiB | | 0 N/A N/A 7744 G /usr/bin/konsole 4MiB | | 0 N/A N/A 1094333 G ...e/Steam/ubuntu12_32/steam 8MiB | | 0 N/A N/A 1094620 G ...buntu12_64/steamwebhelper 43MiB | +-----------------------------------------------------------------------------+
BTW: Running "kcmshell5 qtquicksettings" and forcing software rendering for plasma completely eliminates the issue (with Xorg staying really low on VRAM) but then plasma loudly complains about non-optimal rendering settings and I fear this can even reduce game performance if an application renders in parallel to a game (as can be observed when forcing software rendering for Discord which completely degrades GPU performance while gaming).
I investigated yesterday the memory usage of akonadi and the issue is that each akonadi resources and agents create a connection with X or Wayland which results in a lot of memory usage. I have a simple fix for that https://invent.kde.org/pim/akonadi/-/merge_requests/139 but that require first making sure that each resources and agents don't actually need that connection to open a dialog or a message box and finish porting the config dialogs to a new api. Which will probably take some time. (help is welcome)
Thanks for investigating. I think this example shows that KDE/Plasma should treat VRAM as a valuable resource, and it affects a lot of other KDE background processes, too. So maybe creating some infrastructure to have one single process display dialogues for background processes may be the way forward. But I understand that this is a big change. As a less intrusive interims solution, Akonadi agent and resource processes could be forced to use Qt software rendering only. It probably won't hurt too much because most of these processes only open simple dialogues, and usually probably only in the event of errors or warnings, not as part of working normally. I found that forcing Qt software rendering for the full desktop to eliminate VRAM ballooning but, as already mentioned, I'm not sure how badly it will affect desktop performance, especially if desktops apps need to render in parallel to a game. Also, it somehow prevents window previews on the taskbar to work so it has a visible impact on user experience. But it may be acceptable for Akonadi dialogues for the time until this is fixed. I found no way to force software rendering only for processes launched by Akonadi, it should be as easy as injecting an environment variable into the launcher but I don't know how or where to do that. There's `/usr/share/dbus-1/services/org.freedesktop.Akonadi.Control.service` but I'm not sure if this is the right place for trying to inject environment variables, or if that is the launcher of the main process at all...