On 2015-04-14 03:04 PM, Sergi Vladykin wrote:
Guys,

There is an important performance issue with Database.allocateObjectId(). Over 
time it becomes slower and slower.


Does this patch help?

Index: src/main/org/h2/engine/Database.java
===================================================================
--- src/main/org/h2/engine/Database.java        (revision 6118)
+++ src/main/org/h2/engine/Database.java        (working copy)
@@ -920,6 +920,7 @@
                     session.log(meta, UndoLogRecord.DELETE, found);
                 }
                 objectIds.clear(id);
+                objectIdsLastClearBit = Math.min(objectIdsLastClearBit, id);
                 if (SysProperties.CHECK) {
                     checkMetaFree(session, id);
                 }
@@ -1421,14 +1422,17 @@
         }
     }

+    private int objectIdsLastClearBit = 0;
+
     /**
      * Allocate a new object id.
      *
      * @return the id
      */
     public synchronized int allocateObjectId() {
-        int i = objectIds.nextClearBit(0);
+        int i = objectIds.nextClearBit(objectIdsLastClearBit);
         objectIds.set(i);
+        objectIdsLastClearBit = i;
         return i;
     }


--
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/d/optout.

Reply via email to