From: stevenknight Date: Thu, 3 Jan 2002 17:41:32 +0000 (+0000) Subject: Signature performance improvements (Charles Crain). X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=71d6b1f8d18ca5fdbc17b3799302f9e7fc36f2ae;p=scons.git Signature performance improvements (Charles Crain). git-svn-id: http://scons.tigris.org/svn/scons/trunk@188 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 45e5f2bf..fc04479e 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -10,6 +10,10 @@ RELEASE 0.03 - + From Charles Crain: + + - Performance improvements in the Node.FS and Sig.Calculator classes. + From Steven Knight: - Search both /usr/lib and /usr/local/lib for scons directories by diff --git a/src/engine/SCons/Sig/SigTests.py b/src/engine/SCons/Sig/SigTests.py index 19816d53..148fc9a6 100644 --- a/src/engine/SCons/Sig/SigTests.py +++ b/src/engine/SCons/Sig/SigTests.py @@ -91,7 +91,7 @@ class DummyNode: self.csig = csig def get_csig(self): - return self.bsig + return self.csig def get_prevsiginfo(self): return (self.oldtime, self.oldbsig, self.oldcsig) @@ -162,6 +162,7 @@ class SigTestBase: self.test_built() self.test_modify() self.test_delete() + self.test_cache() def test_initial(self): @@ -240,7 +241,18 @@ class SigTestBase: self.failUnless(current(calc, nodes[8])) self.failUnless(not current(calc, nodes[9]), "deleted") self.failUnless(current(calc, nodes[10]), - "current even though its source was deleted") + "current even though its source was deleted") + + def test_cache(self): + """Test that signatures are cached properly.""" + nodes = create_nodes(self.files) + + calc = SCons.Sig.Calculator(self.module) + nodes[0].set_csig(1) + nodes[1].set_bsig(1) + assert calc.csig(nodes[0]) == 1, calc.csig(nodes[0]) + assert calc.bsig(nodes[1]) == 1, calc.bsig(nodes[1]) + class MD5TestCase(unittest.TestCase, SigTestBase): """Test MD5 signatures""" diff --git a/src/engine/SCons/Sig/__init__.py b/src/engine/SCons/Sig/__init__.py index 22ec2e9a..25e0d2f8 100644 --- a/src/engine/SCons/Sig/__init__.py +++ b/src/engine/SCons/Sig/__init__.py @@ -159,6 +159,10 @@ class Calculator: #XXX If configured, use the content signatures from the #XXX .sconsign file if the timestamps match. + bsig = node.get_bsig() + if not bsig is None: + return bsig + # Collect the signatures for ALL the nodes that this # node depends on. Just collecting the direct # dependants is not good enough, because @@ -166,7 +170,16 @@ class Calculator: # not include the signatures of its psuedo-sources # (e.g. the signature for a .c file does not include # the signatures of the .h files that it includes). - walker = SCons.Node.Walker(node) + + # However, we do NOT want to walk dependencies of non- + # derived files, because calling get_signature() on the + # derived nodes will in turn call bsig() again and do that + # for us. Hence: + def walk_non_derived(n, myself=node): + if not n.builder or n is myself: + return n.children() + return [] + walker = SCons.Node.Walker(node, walk_non_derived) sigs = [] while 1: child = walker.next() @@ -190,6 +203,10 @@ class Calculator: return None #XXX If configured, use the content signatures from the #XXX .sconsign file if the timestamps match. + csig = node.get_csig() + if not csig is None: + return csig + return self.module.signature(node) def get_signature(self, node):