KSyCoca, Thread safety, and Cache invalidation

Vishesh Handa me at vhanda.in
Sat Jun 13 01:04:03 BST 2015

Hey David

There is a bug in KRunner that new applications do not show up unless
KRunner is restarted. The problem is as follows -

* Every thread has its own KSysCoca instance
* Each KSysCoca interface listens for a dbus signal on when it should
update its db
* Without an event loop, dbus signals are never received.

Since KRunner runs each runner in a separate thread without an event
loop, the threads which the application search runner runs on are
never updated. And newer applications never show up.

Possible ways of fixing this -

1. Modify ThreadWeaver to run a event loop when threads aren't being used.

2. Use only a single KSyCoca instance instead of 1 instance per
thread, and add loads of locking code.

3. The gui thread on receiving the dbus signal updates its db as well
as the database of all other threads. This is slightly complex and
would require locking code similar to (2) since the other threads
could be in the process of using KSycoca.

4. Modify KSycoca so that it re-opens the db on each query. This
probably seems very expensive, but it might not be with the memory
mapped backend.

5. Modify KRunner application runner to always reload the db before each query.

6. Modify the application runner to only run in the gui thread.

I'm not quite sure on how to go about this. Do you have any
suggestions? I'm leaning towards (3), but the locking code is scary.

Vishesh Handa

More information about the kde-core-devel mailing list