From: Tuukka Lehtonen Date: Wed, 17 Jun 2020 13:07:40 +0000 (+0000) Subject: Merge "Fixed bug in cluster collection logic that caused it to not operate" X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=commitdiff_plain;h=ff5dddc885c9b3e6e973cfa3eebe9c3d1013c304;hp=e89ad0dd828fd8c628288d416590b1f8ec0194ef Merge "Fixed bug in cluster collection logic that caused it to not operate" --- 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 200e9e3c1..efb644acd 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 @@ -526,10 +526,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; } }