[Zodb-checkins] CVS: ZODB4/ZODB/tests - testFileStorage.py:1.25 speed.py:1.7 PersistentStorage.py:1.3

Jeremy Hylton jeremy@zope.com
Wed, 11 Dec 2002 18:41:21 -0500

Update of /cvs-repository/ZODB4/ZODB/tests
In directory cvs.zope.org:/tmp/cvs-serv19253/ZODB/tests

Modified Files:
	testFileStorage.py speed.py PersistentStorage.py 
Log Message:
Merge the ZODB4-Q-branch to the trunk.

The primary effect of this change is to use take advantage of the Q
struct format code to simplify FileStorage.  There were many places
where FileStorage used "8s" and then had to call u64() on the result
to convert from an 8-byte string to a Python long.  This was tedious
and added lots of extra noise to the FileStorage code.

Along the way, a lot of other refactoring happened.  Introduce a
FileStorageFormatter that handles most of the details of reading the
low-level FileStorage format.  It returns a simply Python object that
has attributes for each of the fields in a data header.  The formatter
class has been used in many places, but the changes aren't complete.
It should be used for the transaction header and for writing the data
header, but I don't know when I'll get to that.

The pack implementation was refactored a bit.  Most of the logic was
moved to a separate class FileStoragePacker, because the _file
attribute is a separate file object opened on the same underlying file
as the main FileStorage.

Since old-style undo is no longer supported, all the checks for 'u'
were removed and the _sane() method is no longer necessary.

The code passes all the tests, but there are a bunch of corner cases
in pack() that should be tested more thoroughly.  A bunch of branches
aren't executed during the pack tests.

A run of speed.py shows that the code is faster on the whole.  It's
quicker to get the Python long directly from struct than it is to get
an 8s and call another Python function to convert it.  For the speed
tests, the runs with small # of objects are slower (roughly 2x), but
the runs with large # of objects are faster (roughly 50%).

=== ZODB4/ZODB/tests/testFileStorage.py 1.24 => 1.25 ===
--- ZODB4/ZODB/tests/testFileStorage.py:1.24	Fri Dec  6 15:29:11 2002
+++ ZODB4/ZODB/tests/testFileStorage.py	Wed Dec 11 18:40:50 2002
@@ -49,6 +49,7 @@
     def setUp(self):
+        StorageTestBase.removefs("FileStorageTests.fs")
     def tearDown(self):

=== ZODB4/ZODB/tests/speed.py 1.6 => 1.7 ===
--- ZODB4/ZODB/tests/speed.py:1.6	Thu Jul 18 16:26:18 2002
+++ ZODB4/ZODB/tests/speed.py	Wed Dec 11 18:40:50 2002
@@ -76,11 +76,7 @@
         s=ZODB.FileStorage.FileStorage('zeo_speed.fs', create=1)
-    db=ZODB.DB.DB(s,
-               # disable cache deactivation
-               cache_size=4000,
-               cache_deactivate_after=6000,)
+    db=ZODB.DB.DB(s, cache_size=4000)
     results={1:0, 10:0, 100:0, 1000:0}
     for j in range(nrep):
         for r in 1, 10, 100, 1000:

=== ZODB4/ZODB/tests/PersistentStorage.py 1.2 => 1.3 ===
--- ZODB4/ZODB/tests/PersistentStorage.py:1.2	Mon Jun 10 19:27:44 2002
+++ ZODB4/ZODB/tests/PersistentStorage.py	Wed Dec 11 18:40:50 2002
@@ -26,7 +26,6 @@
         self._storage.new_oid = new_oid_wrapper
-        self._dostore('a')
         oid = self._storage.new_oid()
         revid = self._dostore(oid)
         self._dostore(oid, revid, data=8, version='b')