[jboss-cvs] JBoss Messaging SVN: r7133 - in branches/Branch_JBM2_Perf_Clebert: tests/src/org/jboss/messaging/tests/performance/journal and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri May 29 16:14:17 EDT 2009


Author: clebert.suconic at jboss.com
Date: 2009-05-29 16:14:17 -0400 (Fri, 29 May 2009)
New Revision: 7133

Modified:
   branches/Branch_JBM2_Perf_Clebert/src/main/org/jboss/messaging/core/journal/impl/NIOSequentialFile.java
   branches/Branch_JBM2_Perf_Clebert/tests/src/org/jboss/messaging/tests/performance/journal/PerformanceComparissonTest.java
   branches/Branch_JBM2_Perf_Clebert/tests/src/org/jboss/messaging/tests/unit/core/journal/impl/fakes/FakeSequentialFileFactory.java
Log:
tweaks

Modified: branches/Branch_JBM2_Perf_Clebert/src/main/org/jboss/messaging/core/journal/impl/NIOSequentialFile.java
===================================================================
--- branches/Branch_JBM2_Perf_Clebert/src/main/org/jboss/messaging/core/journal/impl/NIOSequentialFile.java	2009-05-29 19:19:01 UTC (rev 7132)
+++ branches/Branch_JBM2_Perf_Clebert/src/main/org/jboss/messaging/core/journal/impl/NIOSequentialFile.java	2009-05-29 20:14:17 UTC (rev 7133)
@@ -74,7 +74,7 @@
    
    public boolean fits(final int size)
    {
-      return this.position.get() + size < fileSize;
+      return this.position.get() + size <= fileSize;
    }
 
    public String getFileName()
@@ -179,6 +179,8 @@
 
    public void write(final ByteBuffer bytes, final boolean sync) throws Exception
    {
+      position.addAndGet(bytes.limit());
+
       channel.write(bytes);
 
       if (sync)

Modified: branches/Branch_JBM2_Perf_Clebert/tests/src/org/jboss/messaging/tests/performance/journal/PerformanceComparissonTest.java
===================================================================
--- branches/Branch_JBM2_Perf_Clebert/tests/src/org/jboss/messaging/tests/performance/journal/PerformanceComparissonTest.java	2009-05-29 19:19:01 UTC (rev 7132)
+++ branches/Branch_JBM2_Perf_Clebert/tests/src/org/jboss/messaging/tests/performance/journal/PerformanceComparissonTest.java	2009-05-29 20:14:17 UTC (rev 7133)
@@ -59,6 +59,8 @@
 
    private final byte UPDATE1 = 2;
 
+   private final byte UPDATE2 = 3;
+
    private final int ITERATIONS = 10;
 
    private final boolean PERFORM_UPDATE = true;
@@ -104,6 +106,116 @@
       // super.tearDown();
    }
 
+   public void testAddDeleteAIO() throws Exception
+   {
+      for (int i = 0; i < ITERATIONS; i++)
+      {
+         if (i > 0)
+         {
+            tearDown();
+            setUp();
+         }
+
+         System.out.println("Test AIO # " + i);
+         testAddDeleteJournal(new AIOSequentialFileFactory(getTestDir(), 100 * 1024, 2),
+                              NUM_RECORDS,
+                              SIZE_RECORD,
+                              13,
+                              10 * 1024 * 1024);
+
+      }
+   }
+
+   public void testAddDeleteNIO() throws Exception
+   {
+      for (int i = 0; i < ITERATIONS; i++)
+      {
+         if (i > 0)
+         {
+            tearDown();
+            setUp();
+         }
+         System.out.println("Test NIO # " + i);
+         testAddDeleteJournal(new NIOSequentialFileFactory(getTestDir()),
+                              NUM_RECORDS,
+                              SIZE_RECORD,
+                              13,
+                              10 * 1024 * 1024);
+      }
+   }
+
+   public void testAddDeleteJournal(SequentialFileFactory fileFactory,
+                                    long records,
+                                    int size,
+                                    int numberOfFiles,
+                                    int journalSize) throws Exception
+   {
+
+      JournalImpl journal = new JournalImpl(journalSize, // 10M.. we believe that's the usual cilinder
+                                            // size.. not an exact science here
+                                            numberOfFiles, // number of files pre-allocated
+                                            true, // sync on commit
+                                            false, // no sync on non transactional
+                                            fileFactory, // AIO or NIO
+                                            "jbm", // file name
+                                            "jbm", // extension
+                                            500); // it's like a semaphore for callback on the AIO layer
+      // this during record writes
+
+      journal.start();
+      journal.load(dummyLoader);
+
+      FakeMessage msg = new FakeMessage(size);
+      FakeQueueEncoding update = new FakeQueueEncoding();
+
+      long timeStart = System.currentTimeMillis();
+      for (long i = 0; i < records; i++)
+      {
+         if (i == WARMUP_RECORDS)
+         {
+            timeStart = System.currentTimeMillis();
+         }
+         journal.appendAddRecord(i, ADD_RECORD, msg);
+         if (PERFORM_UPDATE)
+         {
+            journal.appendUpdateRecord(i, UPDATE1, update);
+         }
+      }
+
+      for (long i = 0; i < records; i++)
+      {
+         journal.appendUpdateRecord(i, UPDATE2, update);
+         journal.appendDeleteRecord(i);
+      }
+
+      System.out.println("Produced records before stop " + (NUM_RECORDS - WARMUP_RECORDS) +
+                         " in " +
+                         (System.currentTimeMillis() - timeStart) +
+                         " milliseconds");
+
+      journal.stop();
+
+      System.out.println("Produced records after stop " + (NUM_RECORDS - WARMUP_RECORDS) +
+                         " in " +
+                         (System.currentTimeMillis() - timeStart) +
+                         " milliseconds");
+
+      journal = new JournalImpl(journalSize, // 10M.. we believe that's the usual cilinder
+                                // size.. not an exact science here
+                                numberOfFiles, // number of files pre-allocated
+                                true, // sync on commit
+                                false, // no sync on non transactional
+                                fileFactory, // AIO or NIO
+                                "jbm", // file name
+                                "jbm", // extension
+                                500); // it's like a semaphore for callback on the AIO layer
+      // this during record writes
+
+      journal.start();
+      journal.load(dummyLoader);
+
+   }
+
    public void testAIO() throws Exception
    {
       for (int i = 0; i < ITERATIONS; i++)

Modified: branches/Branch_JBM2_Perf_Clebert/tests/src/org/jboss/messaging/tests/unit/core/journal/impl/fakes/FakeSequentialFileFactory.java
===================================================================
--- branches/Branch_JBM2_Perf_Clebert/tests/src/org/jboss/messaging/tests/unit/core/journal/impl/fakes/FakeSequentialFileFactory.java	2009-05-29 19:19:01 UTC (rev 7132)
+++ branches/Branch_JBM2_Perf_Clebert/tests/src/org/jboss/messaging/tests/unit/core/journal/impl/fakes/FakeSequentialFileFactory.java	2009-05-29 20:14:17 UTC (rev 7133)
@@ -567,7 +567,7 @@
        */
       public boolean fits(int size)
       {
-         return data.position() + size < data.limit();
+         return data.position() + size <= data.limit();
       }
 
    }




More information about the jboss-cvs-commits mailing list