X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.db.impl%2Fsrc%2Forg%2Fsimantics%2Fdb%2Fimpl%2Fquery%2FQueryCollectorImpl2.java;h=b0e6330700e2fd587d9aa873a0446671ddd1f77d;hp=84273b81d63cf6921be763840b2c0cae172ba934;hb=HEAD;hpb=9f0fd59be54719b1fe9322d8fd37e4950857308c diff --git a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/QueryCollectorImpl2.java b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/QueryCollectorImpl2.java index 84273b81d..b0e633070 100644 --- a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/QueryCollectorImpl2.java +++ b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/QueryCollectorImpl2.java @@ -6,9 +6,10 @@ import java.util.IdentityHashMap; import java.util.List; import java.util.Map; +import org.simantics.databoard.Bindings; import org.simantics.databoard.util.IdentityHashSet; +import org.simantics.db.DevelopmentKeys; import org.simantics.db.common.exception.DebugException; -import org.simantics.db.impl.DebugPolicy; import org.simantics.db.impl.query.QueryProcessor.QueryCollectorSupport; import org.simantics.utils.Development; @@ -28,21 +29,29 @@ class QueryCollectorImpl2 implements QueryProcessor.QueryCollector { private boolean findCollectables(CacheEntry entry, Map collectables, ArrayList result) { if (entry.isDiscarded()) { - if(DebugPolicy.COLLECT && DebugPolicy.VERBOSE) - System.out.println("GC: discarded entry " + entry); + if (Development.DEVELOPMENT) { + if(Development.getProperty(DevelopmentKeys.QUERYCOLLECTOR, Bindings.BOOLEAN)) { + System.err.println("GC: discarded entry " + entry); + } + } return true; } if (entry.isPending()) { - if(DebugPolicy.COLLECT && DebugPolicy.VERBOSE) - System.out.println("GC: pending entry " + entry + " was not collected."); + if (Development.DEVELOPMENT) { + if(Development.getProperty(DevelopmentKeys.QUERYCOLLECTOR, Bindings.BOOLEAN)) { + System.err.println("GC: pending entry " + entry + " was not collected."); + } + } collectables.remove(entry); return false; } - if (this.queryProcessor.hasListenerAfterDisposing(entry)) { - if (DebugPolicy.COLLECT && DebugPolicy.VERBOSE) { - System.out.println("GC: listened entry " + entry + " was not collected. Entry=" + entry); + if (this.queryProcessor.listening.hasListenerAfterDisposing(entry)) { + if (Development.DEVELOPMENT) { + if(Development.getProperty(DevelopmentKeys.QUERYCOLLECTOR, Bindings.BOOLEAN)) { + System.err.println("GC: listened entry " + entry + " was not collected. Entry=" + entry); + } } collectables.remove(entry); return false; @@ -60,8 +69,11 @@ class QueryCollectorImpl2 implements QueryProcessor.QueryCollector { } if(!parentIsCollectable) { - if(DebugPolicy.COLLECT && DebugPolicy.VERBOSE) - System.out.println("GC: due to bound parent " + parent + " the entry + " + entry + " was not collected."); + if (Development.DEVELOPMENT) { + if(Development.getProperty(DevelopmentKeys.QUERYCOLLECTOR, Bindings.BOOLEAN)) { + System.err.println("GC: due to bound parent " + parent + " the entry + " + entry + " was not collected."); + } + } collectables.remove(entry); return false; } @@ -109,8 +121,11 @@ class QueryCollectorImpl2 implements QueryProcessor.QueryCollector { // Compute amount of free queries int freeCount = collectables.size(); - if(DebugPolicy.COLLECT) - System.out.println("collector found " + freeCount + " free queries."); + if (Development.DEVELOPMENT) { + if(Development.getProperty(DevelopmentKeys.QUERYCOLLECTOR, Bindings.BOOLEAN)) { + System.err.println("collector found " + freeCount + " free queries."); + } + } lastKnownFixedSize = currentSize - freeCount; @@ -119,8 +134,13 @@ class QueryCollectorImpl2 implements QueryProcessor.QueryCollector { int target = freeCount - maxNumberOfCollectableQueries/2; - if(DebugPolicy.COLLECT) - System.out.println("collector removes " + target + " free queries."); + + if (Development.DEVELOPMENT) { + if(Development.getProperty(DevelopmentKeys.QUERYCOLLECTOR, Bindings.BOOLEAN)) { + System.err.println("collector found " + freeCount + " free queries."); + System.err.println("collector removes " + target + " free queries."); + } + } for(CacheEntry entry : collectables) { if(queryProcessor.removeQuery(entry)) @@ -139,8 +159,11 @@ class QueryCollectorImpl2 implements QueryProcessor.QueryCollector { removals.clear(); } - if(DebugPolicy.COLLECT) { - System.out.println("collect found " + freeCount + " collectable entries."); + + if (Development.DEVELOPMENT) { + if(Development.getProperty(DevelopmentKeys.QUERYCOLLECTOR, Bindings.BOOLEAN)) { + System.err.println("collect found " + freeCount + " collectable entries."); + } } return; @@ -152,24 +175,34 @@ class QueryCollectorImpl2 implements QueryProcessor.QueryCollector { try { - int current = support.calculateCurrentSize(); - if(DebugPolicy.COLLECT) - new DebugException("checking the need for collecting queries (current=" + current + " , lastKnownFixedSize=" + lastKnownFixedSize + " max free=" + 0 + ")").printStackTrace(); + int current = support.calculateCurrentSize(); + if (Development.DEVELOPMENT) { + if(Development.getProperty(DevelopmentKeys.QUERYCOLLECTOR, Bindings.BOOLEAN)) { + new DebugException("checking the need for collecting queries (current=" + current + " , lastKnownFixedSize=" + lastKnownFixedSize + " max free=" + 0 + ")").printStackTrace(); + } + } + queryProcessor.cache.collecting = true; long start = System.nanoTime(); doCollect(current, 0); - if(DebugPolicy.COLLECT) - System.out.println("collect finished with " + support.calculateCurrentSize() + " entries (lastKnownFixedSize=" + lastKnownFixedSize + ")."); + if (Development.DEVELOPMENT) { + if(Development.getProperty(DevelopmentKeys.QUERYCOLLECTOR, Bindings.BOOLEAN)) { + System.err.println("collect finished with " + support.calculateCurrentSize() + " entries (lastKnownFixedSize=" + lastKnownFixedSize + ")."); + } + } long duration = System.nanoTime() - start; - if(DebugPolicy.COLLECT) - System.err.println("Collect took " + 1e-9*duration + "s."); + if (Development.DEVELOPMENT) { + if(Development.getProperty(DevelopmentKeys.QUERYCOLLECTOR, Bindings.BOOLEAN)) { + System.err.println("Collect took " + 1e-9*duration + "s."); + } + } } catch (Throwable t) { t.printStackTrace();