https://bugs.kde.org/show_bug.cgi?id=525030

--- Comment #5 from Andre <[email protected]> ---
Created attachment 198425
  --> https://bugs.kde.org/attachment.cgi?id=198425&action=edit
Unfiltered strace of plasmashell, 2 s during the loop (strace -f -tt -T, 7
rebuilds; machine-id redacted)

The same loop on another system, still present in Plasma 6.8.2 / KF 6.31. Here
is the unfiltered strace you asked for, plus the directory checks plasmashell
makes right before it decides to rebuild.

Versions: Plasma 6.8.2 (plasma-workspace 6.8.2-1.1, plasma-desktop 6.8.2-1.1,
libplasma 6.8.2-1.1, kwin 6.8.2-2.1); KDE Frameworks 6.31 (kservice 6.31.0-1.1,
kcoreaddons 6.31.0-1.1); Qt 6.12.0 (qt6-base 6.12.0-3, qt6-declarative
6.12.0-4.1); kernel 7.3.1-1-cachyos (Arch based), systemd user session,
Wayland; NVIDIA RTX 5080, open module 615.78.08. One desktop screen (DP-1, 4K,
scale 1.7, HDR); a second output is leased to another compositor and is not a
Plasma screen. Stock widgets only: pager, icons-only task manager, margins
separator, system tray, digital clock, show desktop; folder view desktop. No
Kickoff.

What happens
- ~/.cache/ksycoca6_en-IE_* is replaced about 10 times a second, all the time,
with nothing changing on disk: inotifywait -m -e moved_to ~/.cache counted 315
renames in 30 s.
- plasmashell is the only writer: 6.7 MB in 5 s (/proc/PID/io wchar; the cache
is about 550 KB), against 288 bytes for kded6. No kbuildsycoca6 process runs.
- Cost: 7–12 % of one core around the clock. With the shell stopped for 90 s
the CPU package drew 40.7 W, against 46.0 W and 45.1 W in the 90 s before and
after (RAPL, one sample each).
- It starts again right after every plasmashell start.

One cycle, from strace -f -tt -T (strace slows it: 386 ms per cycle instead of
about 95 ms; times from the rename that ends the previous cycle)

  ms            what plasmashell does
           0.0  rename of the temp file onto ksycoca6_...=, unlink of .lock
           0.6  reopens the database
          2–16  lists every applet: /usr/share/plasma/plasmoids/ (15 entries,
every subdirectory and metadata.json) and
/usr/lib/qt6/plugins/plasma/applets/*.so
            69  inotify_add_watch(~/.cache)
       107–143  reads the database
           144  inotify_add_watch(ksycoca6_...=)
       145–155  lists every applet again
           156  lists /usr/share/plasma/layout-templates/
   156.6–158.3  statx of the directories below, then opens the database again
         158.4  creates .lock and a temp file: the rebuild starts
       271–321  /usr/share/mime (about 4,500 calls)
       321–358  every .desktop file (197 system, 13 user)
           386  rename into place; the next cycle starts

Checks right before the rebuild, with their modification times (UTC, 11-13
09:37):
- the database itself: 09:37:16
- /etc/xdg/menus: 11-06 10:31
- ~/.local/share/applications: 11-06 09:44
- ~/.local/share/mime, /usr/local/share/applications, /usr/local/share/mime:
absent
- /usr/share/applications: 11-13 09:23 (an uninstall that morning; the loop ran
for weeks before it)
- /usr/share/mime and its 13 subdirectories: 11-13 09:15:38–39
- mimeapps.list: 05-06
- kde-mimeapps.list: 10-28

None of them is in the future, and all are older than the database plasmashell
has just written. Nothing in the application, mime or menu directories changes
while the loop runs (recursive inotifywait: 0 events in 15 s).

Unfiltered strace, 2 s (attached; machine-id and one UUID redacted): 93,355
lines, 7 rebuilds. Most frequent calls: statx 37,338; readlink 22,230 (mostly
/usr, /usr/share, /usr/share/applications, each .desktop file); access 12,867
(each .desktop and mime XML); read 4,241; openat 3,421; getdents64 2,112. Also
28 statx("kwin_wayland") calls on a relative path, all ENOENT.

Environment: the same as kded6's apart from per-process variables.
XDG_DATA_DIRS is unset;
XDG_CONFIG_DIRS=/home/andre/.config/kdedefaults:/etc/xdg;
XDG_MENU_PREFIX=plasma-; LANG and every LC_* are en_IE.UTF-8. With
QT_LOGGING_RULES="kf.service.sycoca*=true" every cycle logs, in order: "got a
notifyDatabaseChanged signal", "Opening ksycoca from ...", "Reusing existing
ksycoca", "Recreating ksycoca file (..., version 307)". dbus-monitor shows no
org.kde.KSycoca signals.

Already tried, none stops it:
- kbuildsycoca6 --noincremental plus a plasmashell restart: 64 rebuilds in the
next 20 s.
- Kickoff removed. Before that, Kicker leaked its models on every rebuild:
heaptrack over 8.5 h showed 642 MB leaked, about 450 MB of it from
libkickerplugin.
- KDE Connect uninstalled.
- Panel widgets removed one at a time: with only pager, margins separator,
digital clock and show desktop left, the loop still ran.

To reproduce / check:
1. inotifywait -m -e moved_to ~/.cache | grep ksycoca6: several lines a second,
forever.
2. grep wchar /proc/$(pidof plasmashell)/io, twice, 5 s apart: megabytes.
3. strace -f -tt -p $(pidof plasmashell) -e
trace=openat,statx,rename,inotify_add_watch: the cycle above.

The steps that make a fresh system start doing this are not known.

Hypothesis (not verified): the decision is taken between the directory statx
calls (156.6 ms) and the lock (158.4 ms), and none of those timestamps is newer
than the database. So either the check compares against something other than
these mtimes, or the rebuild is requested without a timestamp check, from a
path reached after the applet list is re-read on databaseChanged.

--
Investigated and written with an AI assistant (Claude) on my behalf; every
measurement above was taken on this machine, and I can run anything else you
need.

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to