Since now KRecentDocument::add parses and add data to an xml files, it can take up to 100ms to do its work. We need to make it not slow down main thread. Using a separate thread makes sense, using a daemon with temporary files could make sense. This caused kate to remove use of `KRecentDocument::add` https://invent.kde.org/utilities/kate/-/commit/18dc91a1e6d29aad27072963a12d960517f9da1b Relates to 420504.
From my profiling that I did at that time, I think the issue was that the xml file kept accumulating entries without ever removing them. So after a while the file would become large and slow down the startup of Kate. The larger the file, the slower Kate's startup. Imo, threads or daemon would be overkill for a such a simple job. Perhaps the recents list could be kept small. Otherwise it would help if a faster xml library for reading the data was used because QXml* is a disaster when it comes to performance.
Checking the chat records of the discussion around this, for me the xbel file at that time was 1.9M waqar 1 Jul 23:34 /home/waqar/.local/share/recently-used.xbel which caused a 100ms slow down, per flie open
(In reply to Waqar Ahmed from comment #1) > From my profiling that I did at that time, I think the issue was that the > xml file kept accumulating entries without ever removing them. So after a > while the file would become large and slow down the startup of Kate. The > larger the file, the slower Kate's startup. > > Imo, threads or daemon would be overkill for a such a simple job. Perhaps > the recents list could be kept small. Otherwise it would help if a faster > xml library for reading the data was used because QXml* is a disaster when > it comes to performance. Reducing the xml file size is one of the objective of https://invent.kde.org/frameworks/kio/-/merge_requests/1196 please review it. This might be enough to fix this bug. But It would need some measurement to confirm.
(In reply to Méven Car from comment #3) > (In reply to Waqar Ahmed from comment #1) > > From my profiling that I did at that time, I think the issue was that the > > xml file kept accumulating entries without ever removing them. So after a > > while the file would become large and slow down the startup of Kate. The > > larger the file, the slower Kate's startup. > > > > Imo, threads or daemon would be overkill for a such a simple job. Perhaps > > the recents list could be kept small. Otherwise it would help if a faster > > xml library for reading the data was used because QXml* is a disaster when > > it comes to performance. > > Reducing the xml file size is one of the objective of > https://invent.kde.org/frameworks/kio/-/merge_requests/1196 please review it. > This might be enough to fix this bug. But It would need some measurement to > confirm. My plan would be to move only the trimming file size part to the daemon. This is a lot slower than adding an entry to the file.