>From c10441da8a1556d6c337fee26b69a4b5d8b482e6 Mon Sep 17 00:00:00 2001 From: Matthieu Patou Date: Mon, 25 May 2015 09:17:55 -0700 Subject: [PATCH 2/4] ldb: create a cache of known wellknown objects instead of continously searching in the db Profiling on dbcheck have shown that we spend 10% of the time looking for wellknown objects. Change-Id: I13ed58e8062d1b7b6179d17b0e7e56f943572c6c Signed-off-by: Matthieu Patou --- python/samba/samdb.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/python/samba/samdb.py b/python/samba/samdb.py index e74e823..29dd6ea 100644 --- a/python/samba/samdb.py +++ b/python/samba/samdb.py @@ -39,6 +39,7 @@ class SamDB(samba.Ldb): """The SAM database.""" hash_oid_name = {} + hash_well_known = {} def __init__(self, url=None, lp=None, modules_dir=None, session_info=None, credentials=None, flags=0, options=None, global_schema=True, @@ -794,7 +795,19 @@ accountExpires: %u return dsdb._dsdb_get_nc_root(self, dn) def get_wellknown_dn(self, nc_root, wkguid): - return dsdb._dsdb_get_wellknown_dn(self, nc_root, wkguid) + h_nc = self.hash_well_known.get(str(nc_root)) + dn = None + if h_nc is not None: + dn = h_nc.get(wkguid) + if dn is None: + dn = dsdb._dsdb_get_wellknown_dn(self, nc_root, wkguid) + if dn is None: + return dn + if h_nc is None: + self.hash_well_known[str(nc_root)] = {} + h_nc = self.hash_well_known[str(nc_root)] + h_nc[wkguid] = dn + return dn def set_minPwdAge(self, value): m = ldb.Message() -- 2.1.4