diff options
author | Steven Knight <knight@baldmt.com> | 2002-01-03 17:41:32 (GMT) |
---|---|---|
committer | Steven Knight <knight@baldmt.com> | 2002-01-03 17:41:32 (GMT) |
commit | 067da47ef2483324946f44272c6a968b2aac2ea7 (patch) | |
tree | d04f3d1f237fbbe01d7ff04ec275e0c55fd34ece | |
parent | 7511301b4ec23b6b54647ae55368aee2e136518a (diff) | |
download | SCons-067da47ef2483324946f44272c6a968b2aac2ea7.zip SCons-067da47ef2483324946f44272c6a968b2aac2ea7.tar.gz SCons-067da47ef2483324946f44272c6a968b2aac2ea7.tar.bz2 |
Signature performance improvements (Charles Crain).
-rw-r--r-- | src/CHANGES.txt | 4 | ||||
-rw-r--r-- | src/engine/SCons/Sig/SigTests.py | 16 | ||||
-rw-r--r-- | src/engine/SCons/Sig/__init__.py | 19 |
3 files changed, 36 insertions, 3 deletions
diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 45e5f2b..fc04479 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 19816d5..148fc9a 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 22ec2e9..25e0d2f 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): |