From: Tuukka Lehtonen Date: Wed, 10 Jun 2020 18:43:29 +0000 (+0300) Subject: Fixed bug in cluster collection logic that caused it to not operate X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=7bf383e9fe2456b7deda8d09c40c9a469b116612;p=simantics%2Fplatform.git Fixed bug in cluster collection logic that caused it to not operate 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 --- diff --git a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/util/SessionGarbageCollection.java b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/util/SessionGarbageCollection.java index c168e2286..c48ec3630 100644 --- a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/util/SessionGarbageCollection.java +++ b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/util/SessionGarbageCollection.java @@ -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); } diff --git a/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/ClusterTable.java b/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/ClusterTable.java index 7df13315f..a52870a15 100644 --- a/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/ClusterTable.java +++ b/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/ClusterTable.java @@ -524,10 +524,11 @@ public final class ClusterTable implements IClusterTable { ArrayList toRelease = new ArrayList(); 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; } }