GNOME Bugzilla – Bug 495077
Property caching scheme does not work
Last modified: 2019-03-27 20:11:58 UTC
Currently in pyatspi we have an issue with the property caching scheme: Every time a paperweight is garbage collected (which happens all the time if you are listening for events), it will delete the cache entry for a certain accessible, even if we are holding a paperweight for that accessible somewhere else. In an application like Orca, which listens to a lot of events, this means that we are virtually not caching.
Created attachment 98782 [details] [review] New caching scheme This patch introduces a global dictionary with weak referenced values. The key is a given accessible's hash, and the value is an old-style class (_PropertyCache) instance that could be annotated with cached info. The dictionary's reference to the cache values is weak, the strong reference comes from slots in the accessible paperweights themselves. So while one or more paperweights of the same accessible are alive, the dictionary entry remains, when all paperweights get deleted, the entry disappears automatically, which is a good thing since the hash values are typically recycled for a new and different accessible. This patch is especially edgy since I introduce parent caching, which gives a large performance boost to Orca. I was at first scared of cyclical references, But so far it works remarkably well, but I might have overlooked something in that, so please look closely at the possibilities of mess-up with parent caching.
Created attachment 98785 [details] [review] New caching scheme This patch adds user_data with global scope (ie. two paperweights of the same accessible will have identical user_data).
Comment on attachment 98785 [details] [review] New caching scheme Yes. This looks like it will work. Needs some cleanup before commit, but the idea is sound.
I committed this a day before Peter's comment. Oops. Peter, is there any specific cleanup you had in mind?
Getting rid of debugging info. (prints)
This problem has been fixed in the development version. The fix will be available in the next major software release. Thank you for your bug report.