db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r635577 - in /db/derby/code/trunk/java/engine/org/apache/derby/impl/services/cache: BackgroundCleaner.java ClockPolicy.java
Date Mon, 10 Mar 2008 15:21:04 GMT
Author: kahatlen
Date: Mon Mar 10 08:21:00 2008
New Revision: 635577

URL: http://svn.apache.org/viewvc?rev=635577&view=rev
Log:
DERBY-2911: Implement a buffer manager using java.util.concurrent classes

Improved comments as suggested in the review.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/services/cache/BackgroundCleaner.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/services/cache/ClockPolicy.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/services/cache/BackgroundCleaner.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/services/cache/BackgroundCleaner.java?rev=635577&r1=635576&r2=635577&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/services/cache/BackgroundCleaner.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/services/cache/BackgroundCleaner.java
Mon Mar 10 08:21:00 2008
@@ -29,8 +29,10 @@
 import org.apache.derby.iapi.services.daemon.Serviceable;
 
 /**
- * A background cleaner which can be used by <code>ConcurrentCache</code> so
- * that it doesn't have to wait for clean operations to finish. When the
+ * A background cleaner that {@code ConcurrentCache} can use to clean {@code
+ * Cacheable}s asynchronously in a background instead of synchronously in the
+ * user threads. It is normally used by the replacement algorithm in order to
+ * make dirty {@code Cacheable}s clean and evictable in the future. When the
  * background cleaner is asked to clean an item, it puts the item in a queue
  * and requests to be serviced by a <code>DaemonService</code> running in a
  * separate thread.
@@ -177,6 +179,8 @@
      * @return <code>false</code>
      */
     public boolean serviceImmediately() {
+        // This method isn't actually used by BasicDaemon, but we still need to
+        // implement it in order to satisfy the Serviceable interface.
         return false;
     }
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/services/cache/ClockPolicy.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/services/cache/ClockPolicy.java?rev=635577&r1=635576&r2=635577&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/services/cache/ClockPolicy.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/services/cache/ClockPolicy.java
Mon Mar 10 08:21:00 2008
@@ -474,8 +474,11 @@
                 // Ask the background cleaner to clean the entry.
                 BackgroundCleaner cleaner = cacheManager.getBackgroundCleaner();
                 if (cleaner != null && cleaner.scheduleClean(e)) {
-                    // Successfully scheduled the clean operation. Move on to
-                    // the next entry.
+                    // Successfully scheduled the clean operation. We can't
+                    // evict it until the clean operation has finished. Since
+                    // we'd like to be as responsive as possible, move on to
+                    // the next entry instead of waiting for the clean
+                    // operation to finish.
                     continue;
                 }
 
@@ -493,6 +496,16 @@
 
             // Clean the entry and unkeep it.
             cacheManager.cleanAndUnkeepEntry(e, dirty);
+
+            // If no one has touched the entry while we were cleaning it, we
+            // could reuse it at this point. The old buffer manager (Clock)
+            // would however under high load normally move on to the next
+            // entry in the clock instead of reusing the one it recently
+            // cleaned. Some of the performance tests performed as part of
+            // DERBY-2911 indicated that not reusing the entry that was just
+            // cleaned made the replacement algorithm more efficient. For now
+            // we try to stay as close to the old buffer manager as possible
+            // and don't reuse the entry immediately.
         }
 
         return null;



Mime
View raw message