activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r829809 - in /activemq/sandbox/activemq-apollo/hawtdb/src: main/java/org/apache/hawtdb/internal/page/ test/java/org/apache/hawtdb/internal/ test/java/org/apache/hawtdb/internal/index/
Date Mon, 26 Oct 2009 14:16:16 GMT
Author: chirino
Date: Mon Oct 26 14:16:15 2009
New Revision: 829809

URL: http://svn.apache.org/viewvc?rev=829809&view=rev
Log:
starting to work on concurrent updating/profiling.


Modified:
    activemq/sandbox/activemq-apollo/hawtdb/src/main/java/org/apache/hawtdb/internal/page/BatchEntry.java
    activemq/sandbox/activemq-apollo/hawtdb/src/main/java/org/apache/hawtdb/internal/page/Commit.java
    activemq/sandbox/activemq-apollo/hawtdb/src/main/java/org/apache/hawtdb/internal/page/HawtPageFile.java
    activemq/sandbox/activemq-apollo/hawtdb/src/main/java/org/apache/hawtdb/internal/page/SnapshotHead.java
    activemq/sandbox/activemq-apollo/hawtdb/src/test/java/org/apache/hawtdb/internal/Benchmarker.java
    activemq/sandbox/activemq-apollo/hawtdb/src/test/java/org/apache/hawtdb/internal/index/BTreeIndexBenchmark.java
    activemq/sandbox/activemq-apollo/hawtdb/src/test/java/org/apache/hawtdb/internal/index/IndexBenchmark.java

Modified: activemq/sandbox/activemq-apollo/hawtdb/src/main/java/org/apache/hawtdb/internal/page/BatchEntry.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo/hawtdb/src/main/java/org/apache/hawtdb/internal/page/BatchEntry.java?rev=829809&r1=829808&r2=829809&view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo/hawtdb/src/main/java/org/apache/hawtdb/internal/page/BatchEntry.java
(original)
+++ activemq/sandbox/activemq-apollo/hawtdb/src/main/java/org/apache/hawtdb/internal/page/BatchEntry.java
Mon Oct 26 14:16:15 2009
@@ -32,4 +32,6 @@
     public SnapshotHead isSnapshotHead() {
         return null;
     }
+    
+    public abstract long getHeadRevision();
 }
\ No newline at end of file

Modified: activemq/sandbox/activemq-apollo/hawtdb/src/main/java/org/apache/hawtdb/internal/page/Commit.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo/hawtdb/src/main/java/org/apache/hawtdb/internal/page/Commit.java?rev=829809&r1=829808&r2=829809&view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo/hawtdb/src/main/java/org/apache/hawtdb/internal/page/Commit.java
(original)
+++ activemq/sandbox/activemq-apollo/hawtdb/src/main/java/org/apache/hawtdb/internal/page/Commit.java
Mon Oct 26 14:16:15 2009
@@ -56,6 +56,11 @@
     
     
     @Override
+    public long getHeadRevision() {
+        return head;
+    }
+    
+    @Override
     public Commit isCommit() {
         return this;
     }
@@ -135,5 +140,5 @@
         out.writeLong(head);
         out.writeObject(updates);
     }
-    
+
 }
\ No newline at end of file

Modified: activemq/sandbox/activemq-apollo/hawtdb/src/main/java/org/apache/hawtdb/internal/page/HawtPageFile.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo/hawtdb/src/main/java/org/apache/hawtdb/internal/page/HawtPageFile.java?rev=829809&r1=829808&r2=829809&view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo/hawtdb/src/main/java/org/apache/hawtdb/internal/page/HawtPageFile.java
(original)
+++ activemq/sandbox/activemq-apollo/hawtdb/src/main/java/org/apache/hawtdb/internal/page/HawtPageFile.java
Mon Oct 26 14:16:15 2009
@@ -127,17 +127,24 @@
     /** Used as read cache */
     ReadCache readCache = new ReadCache();
 
+    //
+    // Profilers like yourkit just tell which mutex class was locked.. so create a different
class for each mutex
+    // so we can more easily tell which mutex was locked.
+    //
+    private static class HOUSE_KEEPING_MUTEX { public String toString() { return "HOUSE_KEEPING_MUTEX";
}}
+    private static class TRANSACTION_MUTEX { public String toString() { return "TRANSACTION_MUTEX";
}}
+
     /** 
      * Mutex for data structures which are used during house keeping tasks like batch
      * management. Once acquired, you can also acquire the TRANSACTION_MUTEX 
      */
-    private final Object HOUSE_KEEPING_MUTEX = "HOUSE_KEEPING_MUTEX";
+    private final HOUSE_KEEPING_MUTEX HOUSE_KEEPING_MUTEX = new HOUSE_KEEPING_MUTEX();
 
     /** 
      * Mutex for data structures which transaction threads access. Never attempt to 
      * acquire the HOUSE_KEEPING_MUTEX once this mutex is acquired.  
      */
-    final Object TRANSACTION_MUTEX = "TRANSACTION_MUTEX";
+    final TRANSACTION_MUTEX TRANSACTION_MUTEX = new TRANSACTION_MUTEX();
     
     /**
      * This is the free page list at the base revision.  It does not 
@@ -212,6 +219,7 @@
     void commit(Snapshot snapshot, ConcurrentHashMap<Integer, Update> pageUpdates)
{
         
         boolean fullBatch=false;
+        Commit commit=null;
         synchronized (TRANSACTION_MUTEX) {
             
             // we need to figure out the revision id of the this commit...
@@ -231,7 +239,6 @@
             }
             rev++;
 
-            Commit commit=null;
             BatchEntry last = openBatch.entries.getTail();
             if( last!=null ) {
                 commit = last.isCommit();
@@ -241,7 +248,8 @@
                 // TODO: figure out how to do the merge outside the TRANSACTION_MUTEX
                 commit.merge(pageFile.allocator(), rev, pageUpdates);
             } else {
-                openBatch.entries.addLast(new Commit(rev, pageUpdates) );
+                commit = new Commit(rev, pageUpdates);
+                openBatch.entries.addLast(commit);
             }
             
             if( openBatch.base == -1 ) {
@@ -256,12 +264,16 @@
         }
         
         if( fullBatch ) {
-            synchronized (HOUSE_KEEPING_MUTEX) {
-                storeBatches(false);
-                // TODO: do the following actions async.
-                syncBatches();
-                performBatches();
-            }
+            flushBatch();
+        }
+    }
+
+    private void flushBatch() {
+        synchronized (HOUSE_KEEPING_MUTEX) {
+            storeBatches(false);
+            // TODO: do the following actions async.
+            syncBatches();
+            performBatches();
         }
     }
     

Modified: activemq/sandbox/activemq-apollo/hawtdb/src/main/java/org/apache/hawtdb/internal/page/SnapshotHead.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo/hawtdb/src/main/java/org/apache/hawtdb/internal/page/SnapshotHead.java?rev=829809&r1=829808&r2=829809&view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo/hawtdb/src/main/java/org/apache/hawtdb/internal/page/SnapshotHead.java
(original)
+++ activemq/sandbox/activemq-apollo/hawtdb/src/main/java/org/apache/hawtdb/internal/page/SnapshotHead.java
Mon Oct 26 14:16:15 2009
@@ -35,9 +35,12 @@
 final class SnapshotHead extends BatchEntry {
 
     final Batch parent;
+    final long headRevision;
     
     public SnapshotHead(Batch parent) {
         this.parent = parent;
+        BatchEntry lastEntry = this.parent.entries.getTail();
+        this.headRevision = (lastEntry == null ? this.parent.head : lastEntry.getHeadRevision())+1;
     }
 
     /** The number of times this snapshot has been opened. */
@@ -47,6 +50,11 @@
         return "{ references: "+this.snapshots+" }";
     }
 
+    @Override
+    public long getHeadRevision() {
+        return headRevision;
+    }
+
     public SnapshotHead isSnapshotHead() {
         return this;
     }
@@ -54,13 +62,20 @@
     public int translatePage(int page) {
         // Look for the page in the previous commits..
         Batch batch = parent;
-        BatchEntry entry = getPrevious();
+        BatchEntry tail = null;
+        BatchEntry entry = this;
         while( true ) {
             if( batch.isPerformed() ) {
                 break;
             }
             
-            while( entry!=null ) {
+            while( true ) {
+                if( tail == null ) {
+                    tail = entry;
+                } else if( !(entry.getHeadRevision() < tail.getHeadRevision()) ) {
+                    break;
+                }
+                
                 Commit commit = entry.isCommit();
                 if( commit !=null ) {
                     Update update = commit.updates.get(page);
@@ -68,13 +83,14 @@
                         return update.page();
                     }
                 }
-                entry = entry.getPrevious();
+                entry = entry.getPreviousCircular();
             }
             
             batch = batch.getPrevious();
             if( batch==null ) {
                 break;
             }
+            tail = null;
             entry = batch.entries.getTail();
         }
         return page;
@@ -83,13 +99,21 @@
     
     public <T> T get(EncoderDecoder<T> marshaller, int page) {
         Batch batch = parent;
-        BatchEntry entry = getPrevious();
+        BatchEntry tail = null;
+        BatchEntry entry = this;
+        
         while( true ) {
             if( batch.isPerformed() ) {
                 break;
             }
             
-            while( entry!=null ) {
+            while( true ) {
+                if( tail == null ) {
+                    tail = entry;
+                } else if( !(entry.getHeadRevision() < tail.getHeadRevision()) ) {
+                    break;
+                }
+                
                 Commit commit = entry.isCommit();
                 if( commit !=null ) {
                     Update update = commit.updates.get(page);
@@ -100,13 +124,14 @@
                         }
                     }
                 }
-                entry = entry.getPrevious();
+                entry = entry.getPreviousCircular();
             }
             
             batch = batch.getPrevious();
             if( batch==null ) {
                 break;
             }
+            tail = null;
             entry = batch.entries.getTail();
         }
         return null;

Modified: activemq/sandbox/activemq-apollo/hawtdb/src/test/java/org/apache/hawtdb/internal/Benchmarker.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo/hawtdb/src/test/java/org/apache/hawtdb/internal/Benchmarker.java?rev=829809&r1=829808&r2=829809&view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo/hawtdb/src/test/java/org/apache/hawtdb/internal/Benchmarker.java
(original)
+++ activemq/sandbox/activemq-apollo/hawtdb/src/test/java/org/apache/hawtdb/internal/Benchmarker.java
Mon Oct 26 14:16:15 2009
@@ -47,6 +47,7 @@
                 execute(actor);
                 success.increment();
             } catch (Throwable e) {
+                e.printStackTrace();
                 failed.increment();
             }
         }

Modified: activemq/sandbox/activemq-apollo/hawtdb/src/test/java/org/apache/hawtdb/internal/index/BTreeIndexBenchmark.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo/hawtdb/src/test/java/org/apache/hawtdb/internal/index/BTreeIndexBenchmark.java?rev=829809&r1=829808&r2=829809&view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo/hawtdb/src/test/java/org/apache/hawtdb/internal/index/BTreeIndexBenchmark.java
(original)
+++ activemq/sandbox/activemq-apollo/hawtdb/src/test/java/org/apache/hawtdb/internal/index/BTreeIndexBenchmark.java
Mon Oct 26 14:16:15 2009
@@ -30,7 +30,7 @@
 public class BTreeIndexBenchmark extends IndexBenchmark {
 
     public BTreeIndexBenchmark() {
-        this.benchmark.setSamples(5);
+        this.benchmark.setSamples(500);
     }
     
     protected Index<Long, Buffer> createIndex(Transaction tx) {

Modified: activemq/sandbox/activemq-apollo/hawtdb/src/test/java/org/apache/hawtdb/internal/index/IndexBenchmark.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo/hawtdb/src/test/java/org/apache/hawtdb/internal/index/IndexBenchmark.java?rev=829809&r1=829808&r2=829809&view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo/hawtdb/src/test/java/org/apache/hawtdb/internal/index/IndexBenchmark.java
(original)
+++ activemq/sandbox/activemq-apollo/hawtdb/src/test/java/org/apache/hawtdb/internal/index/IndexBenchmark.java
Mon Oct 26 14:16:15 2009
@@ -100,7 +100,7 @@
     
     @Test
     public void insert() throws Exception {
-        benchmark.benchmark(1, new BenchmarkAction<IndexActor>("insert") {
+        benchmark.benchmark(10, new BenchmarkAction<IndexActor>("insert") {
             protected void execute(IndexActor actor) throws InterruptedException {
                 actor.benchmarkIndex();
             }



Mime
View raw message