[Neo-report] r2813 jm - in /trunk/neo/client: Storage.py __init__.py

nobody at svn.erp5.org nobody at svn.erp5.org
Thu Sep 1 18:00:36 CEST 2011


Author: jm
Date: Thu Sep  1 18:00:35 2011
New Revision: 2813

Log:
client: optimize by not calling lastTransaction at the end of transactions

Modified:
    trunk/neo/client/Storage.py
    trunk/neo/client/__init__.py

Modified: trunk/neo/client/Storage.py
==============================================================================
--- trunk/neo/client/Storage.py [iso-8859-1] (original)
+++ trunk/neo/client/Storage.py [iso-8859-1] Thu Sep  1 18:00:35 2011
@@ -126,8 +126,10 @@ class Storage(BaseStorage.BaseStorage,
         return self.app.tpc_abort(transaction=transaction)
 
     def tpc_finish(self, transaction, f=None):
-        return self.app.tpc_finish(transaction=transaction,
+        tid = self.app.tpc_finish(transaction=transaction,
             tryToResolveConflict=self.tryToResolveConflict, f=f)
+        self._snapshot_tid = add64(tid, 1)
+        return tid
 
     @check_read_only
     def store(self, oid, serial, data, version, transaction):
@@ -209,9 +211,6 @@ class Storage(BaseStorage.BaseStorage,
             raise KeyError
 
     def sync(self, force=True):
-        # XXX: Unfortunately, we're quite slow (lastTransaction) and
-        #      we're also called at the end of each transaction by ZODB
-        #      (see Connection.afterCompletion), probably for no useful reason.
         # Increment by one, as we will use this as an excluded upper
         # bound (loadBefore).
         self._snapshot_tid = add64(self.lastTransaction(), 1)

Modified: trunk/neo/client/__init__.py
==============================================================================
--- trunk/neo/client/__init__.py [iso-8859-1] (original)
+++ trunk/neo/client/__init__.py [iso-8859-1] Thu Sep  1 18:00:35 2011
@@ -51,10 +51,10 @@ if needs_patch:
     Connection.tpc_finish = tpc_finish
 
     try:
-        if Connection._nexedi_fix != 1:
+        if Connection._nexedi_fix != 2:
             raise Exception("A different ZODB fix is already applied")
     except AttributeError:
-        Connection._nexedi_fix = 1
+        Connection._nexedi_fix = 2
 
         # Whenever an connection is opened (and there's usually an existing one
         # in DB pool that can be reused) whereas the transaction is already
@@ -88,6 +88,16 @@ if needs_patch:
             Connection_open = Connection.open
             Connection.open = open
 
+        # Storage.sync usually implements a "network barrier" (at least
+        # in NEO, but ZEO should be fixed to do the same), which is quite
+        # slow so we prefer to not call it where it's not useful.
+        # I don't know any legitimate use of DB access outside a transaction.
+
+        def afterCompletion(self, *ignored):
+            self._readCurrent.clear()
+            self._flush_invalidations()
+        Connection.afterCompletion = afterCompletion
+
 
     class _DB(object):
         """




More information about the Neo-report mailing list