X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.db.impl%2Fsrc%2Forg%2Fsimantics%2Fdb%2Fimpl%2Fquery%2FQueryCollectorImpl.java;fp=bundles%2Forg.simantics.db.impl%2Fsrc%2Forg%2Fsimantics%2Fdb%2Fimpl%2Fquery%2FQueryCollectorImpl.java;h=8ea760b75c4a8774a2454f6b2393aed8a388975d;hb=3850fec72035293b9a4ede780d01aedc5fbc9056;hp=965f1e39f41fb1dc4d99000d533c03dde6c21da3;hpb=1e957fc9da518f3bef8a2c19cad72772087e1b6a;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/QueryCollectorImpl.java b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/QueryCollectorImpl.java index 965f1e39f..8ea760b75 100644 --- a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/QueryCollectorImpl.java +++ b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/QueryCollectorImpl.java @@ -29,10 +29,11 @@ class QueryCollectorImpl implements QueryProcessor.QueryCollector { */ boolean propagate = true; - private static final int COLLECT_N = 1000; + private long allowance = 100; private long spent = 0; + private long collectionCounter = 0; QueryCollectorImpl(QueryProcessor queryProcessor, QueryCollectorSupport support) { this.queryProcessor = queryProcessor; @@ -41,14 +42,28 @@ class QueryCollectorImpl implements QueryProcessor.QueryCollector { @Override public void collect(int youngTarget, int allowedTimeInMs) { - + long start = System.nanoTime(); // Refresh current size int size = support.calculateCurrentSize(); + +// if(collectionCounter > allowance) { +// collectionCounter = 0; +// allowance = (allowance * 1100) / 1000; +// } + int bound = queryProcessor.boundQueries; int young = size - bound; int youngPct = size > 0 ? 100*young / size : 0; + + // System.err.println("Collect size = " + size + " bound=" + bound + " allowance=" + allowance); + + // Allowance maintains a reasonable set of queries + if(size < allowance) return; + + // No need to collect anything if the amount of free queries is small compared to the amount of bound queries + if(youngPct < youngTarget) return; // Initialize support for new run // If support returns 0 we are starting from 0 @@ -182,6 +197,7 @@ class QueryCollectorImpl implements QueryProcessor.QueryCollector { support.remove(); propagate = true; moreAll++; + collectionCounter++; doneAll = false; return true; }