summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthieu Patou <mat@matws.net>2015-05-25 09:17:55 -0700
committerStefan Metzmacher <metze@samba.org>2015-09-03 09:11:35 +0200
commitb5c196ac277a756159a03aa02c0ba424247491f5 (patch)
treeae977812434d6fd67e39a63347453160179a4442
parente120381231056277a604fb5a73d5847439cd1851 (diff)
downloadsamba-b5c196ac277a756159a03aa02c0ba424247491f5.tar.gz
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. BUG: https://bugzilla.samba.org/show_bug.cgi?id=10973 Change-Id: I13ed58e8062d1b7b6179d17b0e7e56f943572c6c Signed-off-by: Matthieu Patou <mat@matws.net> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org> (cherry picked from commit 6122acad0f1a7bc23b6f58862c16968e13da979d)
-rw-r--r--python/samba/samdb.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/python/samba/samdb.py b/python/samba/samdb.py
index e3a6292bb4a..817fbdb697b 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,
@@ -793,7 +794,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()