Univention Bugzilla – Bug 41999
Quadratic scaling in s4cache.py (speed up _update_entry)
Last modified: 2016-09-29 17:31:06 CEST
Created attachment 7871 [details] Patch against r71582 UCS 4.1-2, but will probably work with many other versions The attached patch adds indexes to enable efficient lookup by data.guid_id (and data.attribute_id) (as used by _update_entry() by get_entry() by remove_entry() ) by attributes.attribute (as used by _get_attr_id() by _update_entry() ) by guids.guid (as used by _get_guid_id() ) to the SQLite database of the S4Cache, if they do not already exist, during __init__(). Otherwise more objects lead to more work per object, i.e. quadratic complexity. Customer reported speedup from 10s of seconds per object to 10s of objects per second. Additionally the patch adds indexes to enable efficient lookup by s4_lock.guid (as used by is_s4_locked() by unlock_s4() ) by ucs_lock.uuid (as used by is_ucs_locked() by unlock_ucs() ) to the SQLite database of the LockingDB, if they do not already exist, during __init__(). Otherwise more locks lead to more work per lock, i.e. quadratic complexity. Finally I note that self.s4cache in LockingDB.__init__() seems like dead code and self.s4cache in S4Cache.__init__() and .add_entry() seems like unused code or a waste of memory .
Patch applied. Advisory: univention-s4-connector.yaml Tests: OK
YAML: OK Code review 4.1-3 (r71908): OK Code review 4.2 (r71909): OK Tests: OK ucs-test: OK
<http://errata.software-univention.de/ucs/4.1/255.html>