jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r1526489 - in /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak: cache/EmpiricalWeigher.java plugins/mongomk/MongoMK.java
Date Thu, 26 Sep 2013 13:50:38 GMT
Author: mreutegg
Date: Thu Sep 26 13:50:38 2013
New Revision: 1526489

URL: http://svn.apache.org/r1526489
Log:
OAK-1041: Inaccurate size estimate in EmpiricalWeigher

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/cache/EmpiricalWeigher.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoMK.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/cache/EmpiricalWeigher.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/cache/EmpiricalWeigher.java?rev=1526489&r1=1526488&r2=1526489&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/cache/EmpiricalWeigher.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/cache/EmpiricalWeigher.java
Thu Sep 26 13:50:38 2013
@@ -30,7 +30,10 @@ public class EmpiricalWeigher implements
 
     @Override
     public int weigh(String key, CacheValue value) {
-        return 48 + key.length() * 2 + value.getMemory();
+        int size = 168;                 // overhead for each cache entry
+        size += 48 + key.length() * 2;  // string key
+        size += value.getMemory();      // value
+        return size;
     }
     
 }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoMK.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoMK.java?rev=1526489&r1=1526488&r2=1526489&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoMK.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoMK.java
Thu Sep 26 13:50:38 2013
@@ -1319,7 +1319,11 @@ public class MongoMK implements MicroKer
                 set.addAll(c.children);
             }
             set.removeAll(removed);
-            set.addAll(added);
+            for (String name : added) {
+                // make sure the name string does not contain
+                // unnecessary baggage
+                set.add(new String(name));
+            }
             c2.children.addAll(set);
             nodeChildrenCache.put(key, c2);
         }
@@ -1335,13 +1339,17 @@ public class MongoMK implements MicroKer
                     for (String childPath : added) {
                         String name = PathUtils.getName(childPath);
                         if (names.higher(name) != null) {
-                            names.add(name);
+                            // make sure the name string does not contain
+                            // unnecessary baggage
+                            names.add(new String(name));
                         }
                     }
                 } else {
                     // add all
                     for (String childPath : added) {
-                        names.add(PathUtils.getName(childPath));
+                        // make sure the name string does not contain
+                        // unnecessary baggage
+                        names.add(new String(PathUtils.getName(childPath)));
                     }
                 }
                 // any changes?



Mime
View raw message