[Rpm-metadata] [PATCH] switch --update to use the sqlite dbs instead of the xml files. Should massively impact memory footprint and hopefully only marginally impact performance.

Dennis Gregorovic dgregor at redhat.com
Wed Sep 7 16:18:48 UTC 2011


On Fri, 2011-07-15 at 17:53 -0400, Seth Vidal wrote:
> -    def getNodes(self, relpath):
> -        """Return base, filelist, and other nodes for file, if they exist
>  
> -        Returns a tuple of nodes, or None if not found
> +    def getNodes(self, relpath):
> +        """return a package object based on relative path of pkg
>          """
> -        bnode = self.basenodes.get(relpath,None)
> -        if bnode is None:
> -            return None
> -        pkgid = self.pkg_ids.get(relpath,None)
> -        if pkgid is None:
> -            print _("No pkgid found for: %s") % relpath
> -            return None
> -        fnode = self.filesnodes.get(pkgid,None)
> -        if fnode is None:
> -            return None
> -        onode = self.othernodes.get(pkgid,None)
> -        if onode is None:
> -            return None
> -        return bnode, fnode, onode
> -
> -    def freeNodes(self,relpath):
> -        #causing problems
> -        """Free up nodes corresponding to file, if possible"""
> -        bnode = self.basenodes.get(relpath,None)
> -        if bnode is None:
> -            print "Missing node for %s" % relpath
> -            return
> -        bnode.unlinkNode()
> -        bnode.freeNode()
> -        del self.basenodes[relpath]
> -        pkgid = self.pkg_ids.get(relpath,None)
> -        if pkgid is None:
> -            print _("No pkgid found for: %s") % relpath
> +        if relpath in self.pkg_tups_by_path:
> +            pkgtup = self.pkg_tups_by_path[relpath]
> +            return self._repo.sack.searchPkgTuple(pkgtup)[0]
> +        else:
> +            print _("No pkg found for: %s") % relpath
>              return None

Seth,

Thank you very much for this patch.  I've locally backported it to RHEL
6 and the memory savings are tremendous.  However, I just noticed one
small issue.  Before, the getNodes call would only print "No pkg found
for: %" when a package was found in the basenodes cache but not the
pkg_ids cache.  That was an edge condition that never actually happened
as far as I can tell, so the net effect was that "No pkg found" did not
get printed.  After the code change, "No pkg found" is now printed every
time getNodes is called with a package that isn't cached.  

-- Dennis



More information about the Rpm-metadata mailing list