]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Fixed bug in cluster collection logic that caused it to not operate 09/4309/3
authorTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Wed, 10 Jun 2020 18:43:29 +0000 (21:43 +0300)
committerTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Wed, 10 Jun 2020 18:59:20 +0000 (18:59 +0000)
In case the first encountered resident cluster happened to be large
enough to cover the requested cluster collection size, the code would
collect no clusters at all.

Also contains improvements to dynamic cluster collection.

gitlab #556

Change-Id: I75773c688a4fec75d303493ca861c9a73071deac

bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/util/SessionGarbageCollection.java
bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/ClusterTable.java

index c168e22860b25dba84ff1b715376c4a878effcfb..c48ec36309e601cf885f9b8125f16f7e79c579f8 100644 (file)
@@ -76,7 +76,18 @@ public class SessionGarbageCollection {
         QueryControl qc = graph.getService(QueryControl.class);
         ClusterControl cc = graph.getService(ClusterControl.class);
         _monitor.beginTask("Collect clusters", IProgressMonitor.UNKNOWN);
-        cc.gc(graph, clusterTarget);
+        //cc.gc(graph, clusterTarget);
+        if(clusterTarget == -1) {
+            int used = cc.used();
+            //System.err.println("session gc, cluster use = " + used);
+            int baseline = 32*(1<<20);
+            if(used > baseline) {
+                int dynamicTarget = (int)(0.95 * (used-baseline)) + baseline;
+                cc.gc(graph, dynamicTarget);
+            }
+        } else {
+            cc.gc(graph, clusterTarget);
+        }
         _monitor.beginTask("Collect queries", IProgressMonitor.UNKNOWN);
         qc.gc(graph, allowedTimeInMs);
     }
index 7df13315f8f68b093fdbf6cb91b0359b5bb909e1..a52870a1560301e6e372210d827818785fc217c1 100644 (file)
@@ -524,10 +524,11 @@ public final class ClusterTable implements IClusterTable {
                 ArrayList<CollectorCluster> toRelease = new ArrayList<CollectorCluster>();
 
                 for (CollectorCluster cluster : support.getResidentClusters()) {
-                    target -= support.getClusterSize(cluster);
-                    if (target > 0) {
-                        toRelease.add(cluster);
-                    } else {
+                    toRelease.add(cluster);
+                    long clusterSize = support.getClusterSize(cluster);
+                    //System.err.println("release cluster with " + (clusterSize/1024) + " kiB - " + cluster);
+                    target -= clusterSize;
+                    if (target <= 0) {
                         break;
                     }
                 }