Hi!
This patch adds by name caches to the RpmSack.searchPrco() and
.searchFiles() which are the base for most search operations. For an 1000
pkg F8 to devel update this save approx. 25% of the depsolving time without
changing the memory footprint significantly.
I'll run my test suite to make sure there isn't a cost for some other
scenarios but this is quite unlikely. If nothing turns out I am going to
commit that changes tomorrow.
Have fun
Florian
>From 6b7245f8e5b68bad3af7d4d2345f48fcb6a13baa Mon Sep 17 00:00:00 2001
From: Florian Festi <[EMAIL PROTECTED]>
Date: Mon, 10 Dec 2007 18:53:34 +0100
Subject: [PATCH] Add caching for RpmSack.searchPrco/searchFiles
---
yum/rpmsack.py | 25 ++++++++++++++++++++++---
1 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/yum/rpmsack.py b/yum/rpmsack.py
index 5081070..ad2cfd3 100644
--- a/yum/rpmsack.py
+++ b/yum/rpmsack.py
@@ -50,6 +50,13 @@ class RPMDBPackageSack(PackageSackBase):
self._header_dict = {}
self._header_by_name = {}
self.ts = None
+ self._cache = {
+ 'files' : { },
+ 'provides' : { },
+ 'requires' : { },
+ 'conflicts' : { },
+ 'obsoletes' : { },
+ }
def _get_pkglist(self):
'''Getter for the pkglist property.
@@ -102,6 +109,11 @@ class RPMDBPackageSack(PackageSackBase):
def searchFiles(self, name):
"""search the filelists in the rpms for anything matching name"""
+
+ result = self._cache['files'].get(name)
+ if result is not None:
+ return result
+
ts = self.readOnlyTS()
result = {}
@@ -112,11 +124,16 @@ class RPMDBPackageSack(PackageSackBase):
result[pkg.pkgid] = pkg
del mi
-
- return result.values()
+ result = result.values()
+ self._cache['files'][name] = result
+ return result
def searchPrco(self, name, prcotype):
+ result = self._cache[prcotype].get(name)
+ if result is not None:
+ return result
+
ts = self.readOnlyTS()
result = {}
tag = self.DEP_TABLE[prcotype][0]
@@ -140,7 +157,9 @@ class RPMDBPackageSack(PackageSackBase):
del mi
- return result.values()
+ result = result.values()
+ self._cache[prcotype][name] = result
+ return result
def searchProvides(self, name):
return self.searchPrco(name, 'provides')
--
1.5.3.3
_______________________________________________
Yum-devel mailing list
[email protected]
https://lists.dulug.duke.edu/mailman/listinfo/yum-devel