Bug 500180 - Long time to start Plasma due to old kactivitymanagerd database full of history from years in the past
Summary: Long time to start Plasma due to old kactivitymanagerd database full of histo...
Status: RESOLVED FIXED
Alias: None
Product: plasmashell
Classification: Plasma
Component: Startup process (other bugs)
Version First Reported In: 6.0.0
Platform: Manjaro Linux
: NOR normal
Target Milestone: 1.0
Assignee: Plasma Bugs List
URL:
Keywords: efficiency-and-performance
Depends on:
Blocks:
 
Reported: 2025-02-16 12:38 UTC by zxvb12z
Modified: 2025-06-21 20:27 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In: 6.5.0
Sentry Crash Report:


Attachments
journalctl -b (222.90 KB, text/plain)
2025-02-18 18:08 UTC, zxvb12z
Details
gwenview log (132.70 KB, image/png)
2025-02-26 12:51 UTC, zxvb12z
Details

Note You need to log in before you can comment on or make changes to this bug.
Description zxvb12z 2025-02-16 12:38:08 UTC
SUMMARY
After logging in, you have to wait for about 2 minutes for the desktop and panel to appear. While widgets appear almost immediately and you can see them on a completely black screen. I tried to turn off the splash screen, but it didn’t change anything.
This applies only to the first start. When re-logging in, this will not happen until the computer is turned off and turned on again.

STEPS TO REPRODUCE
1. turned on pc
2. login 
3. wait

OBSERVED RESULT
After logging in, you have to wait for about 2 minutes for the desktop and panel to appear.

EXPECTED RESULT
After logging in, no need to wait 2 minutes for the desktop and panel to appear.

SOFTWARE/OS VERSIONS
Linux: Manjaro 25.0
KDE Plasma Version: 6.3, wayland
KDE Frameworks Version: 6.11
Qt Version: 6.8.2
Nvidia video driver: 570.86.16 witch close kernel module
Comment 1 Nate Graham 2025-02-18 16:12:38 UTC
Three questions for you:
1. Is this a regression from Plasma 6.2?
2. Does it happen on X11 as well, or only on Wayland?
3. Can you use `journalctl` to get a log of what was going on during that time? Hopefully that will shed some light on the situation.
Comment 2 zxvb12z 2025-02-18 18:08:04 UTC
Created attachment 178535 [details]
journalctl -b
Comment 3 zxvb12z 2025-02-18 18:21:43 UTC
(In reply to Nate Graham from comment #1)
> Three questions for you:
> 1. Is this a regression from Plasma 6.2?
> 2. Does it happen on X11 as well, or only on Wayland?
> 3. Can you use `journalctl` to get a log of what was going on during that
> time? Hopefully that will shed some light on the situation.

1) No, actually it started happening a long time ago, in version 6.0 or 6.1. this definitely did not happen in 5.x
2) both
3) I added the boot log as a file

systemd-analyze gives the following:
Startup finished in 25.141s (firmware) + 52.612s (loader) + 14.238s (kernel) + 56.528s (userspace) = 2min 28.521s
graphical.target reached after 51.176s in userspace.

but unfortunately I can only working with system after ~4 minutes from start up. I know this number fairly accurately because I have working conky , where up time displayed.  I can almost immediately call yakuake by pressing F12, but unfortunately have to wait for the appearance of panel and desktop.

I have been trying to understand the reason for this for a long time and didn’t want to report it. 

I have a guess that some parameters left after KDE Plasma 5.x and may interfere, I will check this by creating a new user.

Maybe it’s just related to btrfs working on hdd, but I think that’s not the only reason
Comment 4 zxvb12z 2025-02-18 21:41:24 UTC
I create a new user for him start is fast. 
Is there any way to debug this?
I can gradually transfer all my settings from the old user, and see what might cause this, but it will take a long time
Comment 5 zxvb12z 2025-02-25 10:49:26 UTC
I found the source of the problem, it’s /home/username/.local/share/kactivitymanagerd/
if you delete this folder, everything will work without delay. What is it and why is it need ? 
I read the description https://github.com/KDE/kactivitymanagerd and https://invent.kde.org/plasma/kactivitymanagerd
and still don’t understand his purpose. I see that there is a database stored in it, what is written into it ?
In my old folder (before deletion) it weighed 130+ MiB, now It’s 570 KiB. 
There is also a file errors.log, in it error: near ".": syntax error Unable to execute statement.
Comment 6 zxvb12z 2025-02-25 10:57:47 UTC
Hundreds of thousands of records about what files I opened and looked at, seriously ? Is it really necessary?
Comment 7 cwo 2025-02-26 11:38:00 UTC
(In reply to orangeanatola from comment #6)
> Hundreds of thousands of records about what files I opened and looked at,
> seriously ? Is it really necessary?

You can configure the period of data it will save in System Settings > Recent Files. That's mostly what it's there for; krunner will also prioritize files you opened previously at a higher ranking.

If it's set to save history "forever" it can indeed get huge after using Plasma for years, and storing information about possibly long-deleted files is likely not necessary for most people. Trying it on a new user account this seems to be the default, which is maybe not optimal.
Comment 8 zxvb12z 2025-02-26 12:50:20 UTC
(In reply to cwo from comment #7)
> (In reply to orangeanatola from comment #6)
> > Hundreds of thousands of records about what files I opened and looked at,
> > seriously ? Is it really necessary?
> 
> You can configure the period of data it will save in System Settings >
> Recent Files. That's mostly what it's there for; krunner will also
> prioritize files you opened previously at a higher ranking.
> 
> If it's set to save history "forever" it can indeed get huge after using
> Plasma for years, and storing information about possibly long-deleted files
> is likely not necessary for most people. Trying it on a new user account
> this seems to be the default, which is maybe not optimal.

I found these settings before, here you can specify for which applications to store history, but it does not seem to work. 
For example, I am now disabled to store history for gwenview, but if I open the database I see that new records are still being created
I’ll add a screenshot.
Comment 9 zxvb12z 2025-02-26 12:51:22 UTC
Created attachment 178893 [details]
gwenview log
Comment 10 zxvb12z 2025-02-27 11:54:12 UTC
At least the complete disable history recording  works properly. Maybe disabling this by default would be a good idea. 
So what’s next ? I leave this discussion as it is or finish it?
Comment 11 Bug Janitor Service 2025-03-14 03:47:04 UTC
🐛🧹 ⚠️ This bug has been in NEEDSINFO status with no change for at least 15 days. Please provide the requested information, then set the bug status to REPORTED. If there is no change for at least 30 days, it will be automatically closed as RESOLVED WORKSFORME.

For more information about our bug triaging procedures, please read https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging.

Thank you for helping us make KDE software even better for everyone!
Comment 12 Nate Graham 2025-05-28 20:00:00 UTC
We can evaluate limiting the amount of history it will store by default.
Comment 13 Bug Janitor Service 2025-06-10 20:30:39 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kactivitymanagerd/-/merge_requests/88
Comment 14 Bug Janitor Service 2025-06-10 20:32:00 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/plasma-desktop/-/merge_requests/3061
Comment 15 Nate Graham 2025-06-15 20:54:13 UTC
Git commit 45ff7f7cf8cb4e4b616bd0801e937b0a03b447da by Nate Graham.
Committed on 13/06/2025 at 17:06.
Pushed by meven into branch 'master'.

Limit history collection to 4 months by default

This solves two problems:
1. Really old data is likely not very useful, as people's usages and
   projects change over time.
2. Keeping all data forever causes the database to become unbounded in
   size, which will eventually cause performance issues.
FIXED-IN: 6.4.0

M  +1    -1    src/service/plugins/sqlite/StatsPlugin.cpp

https://invent.kde.org/plasma/kactivitymanagerd/-/commit/45ff7f7cf8cb4e4b616bd0801e937b0a03b447da