<div dir="ltr"><div>Hey everyone<br><br></div><div>( This is a slightly long email )<br><br></div><div><b>History:</b><br></div><div><br>One of the main classes in Nepomuk is called the Resource class. It's basically just a cache of the resource data (You can imagine it to be a hash, with properties which contain values - QHash<Property, Value>).<br>
<br></div><div>From the early days, the Resource class has suffered from a problem of cache invalidation - Another application might change some property of the resource and the cache wouldn't have been updated. In 4.8 we introduced new asynchronous APIs. These helped to fix the problem by using a special ResourceWatcher which worked by subscribing to certain signals over dbus.<br>
</div><div><div><br></div><div>With 4.8, each application contains a global static ResourceWatcher who is responsible to update every Resource's internal cache. ( Slightly simplified explanation )<br><b><br></b></div>
<div><b>The Problem:</b><br></div><div><br></div><div>Having each Resource class listen for signals over dbus creates a lot of unnecessary traffic, which slows down certain applications. This is specially prevalent for resources that are created for very small amounts of time.<br>
</div><br><div>Additionally, applications are not informed that the internal data has changed. If they wish to be informed, they need to create their own ResourceWatcher instance, and listen for changes. This is what Dolphin does. Unfortunately, that also results in another problem - Since the ResourceWatcher is just listening to dbus signals, we have no way of knowing which ResourceWatcher's slot will be called first -<br>
<br></div><div>1. The Dolphin one<br></div><div>2. Nepomuk Resource update cache one<br><br></div><div>If (1) happens before (2) and it accesses the cached data, it will result in it accessing stale information.<br><br></div>
<div>Fortunately, Dolphin doesn't suffer from this problem cause it doesn't keep any Resource objects around. So there is no cache to update.<br></div><div><b><br></b></div><div><b>Consequences:</b><br><br></div><div>
1. Loads of additional traffic over dbus whenever a Resource is created. This is done extensively by Dolphin and KMail.<br><br></div><div>2. Enhanced load of the Nepomuk-Storage to inform all the ResourceWatchers. This problem is intensified by a Qt bug [1] which resulted in a large amount of cycles being spent in emitting these signals.<br>
<br></div><div>3. Non-documented slightly unpredictable behaviour when using Resources and ResourceWatchers. <br></div><div><br></div><div><b>Possible Solutions:</b><br><br></div><div>1. Add an explicit Resource::setWatchEnabled( bool ) function in the Resource class which clients can call if they want updates.<br>
</div><div><b><br></b></div><div>2. Disable this automatic updating all together.<br></div><div><b><br></b></div><div><b>When should this be done?<br><br></b></div><div>I would like to do it in the 4.10 series. Maybe 4.10.1 or 4.10.0? But it would involve adding a new public function. Otherwise there is always 4.11.<br>
</div><div><b><br></b></div><div>Currently, no applications depend on this "automatic-updating" behaviour of the Resource class. Also, this behaviour was never advertised.<br><br>Opinions?<br><br>[1] <a href="https://codereview.qt-project.org/45163">https://codereview.qt-project.org/45163</a><br>
<br></div><div>-- <br><span style="color:rgb(192,192,192)">Vishesh Handa</span><br>
</div></div></div>