diff --git a/defaults/yacy.init b/defaults/yacy.init index ae70b9162..25769d1a8 100644 --- a/defaults/yacy.init +++ b/defaults/yacy.init @@ -442,6 +442,7 @@ seedScpPath= peerCycle=2 # debug flags +debug.search.profiling=false debug.search.local.dht.off=false debug.search.local.solr.off=false debug.search.remote.dht.off=false diff --git a/source/net/yacy/cora/federate/solr/connector/EmbeddedSolrConnector.java b/source/net/yacy/cora/federate/solr/connector/EmbeddedSolrConnector.java index 10d36a9c9..7b5c104d5 100644 --- a/source/net/yacy/cora/federate/solr/connector/EmbeddedSolrConnector.java +++ b/source/net/yacy/cora/federate/solr/connector/EmbeddedSolrConnector.java @@ -30,6 +30,7 @@ import java.util.concurrent.LinkedBlockingQueue; import net.yacy.cora.federate.solr.instance.EmbeddedInstance; import net.yacy.cora.federate.solr.instance.SolrInstance; import net.yacy.cora.util.ConcurrentLog; +import net.yacy.search.Switchboard; import net.yacy.search.schema.CollectionSchema; import org.apache.lucene.document.Document; @@ -245,6 +246,17 @@ public class EmbeddedSolrConnector extends SolrServerConnector implements SolrCo @Override public Set existsByIds(Set ids) { + boolean debug = Switchboard.getSwitchboard().getConfigBool("debug.search.profiling", false); + long debugSingleTime = 0; int debugSingleCount = 0; + if (debug) { + // run this also with single exist queries which might be faster (but we don't know, thats the reason we test that here) + long start = System.currentTimeMillis(); + Set idsr = new HashSet(); + for (String id: ids) if (existsById(id)) idsr.add(id); + debugSingleTime = System.currentTimeMillis() - start; + debugSingleCount = idsr.size(); + } + long start = System.currentTimeMillis(); if (ids == null || ids.size() == 0) return new HashSet(); if (ids.size() == 1) return existsById(ids.iterator().next()) ? ids : new HashSet(); StringBuilder sb = new StringBuilder(); // construct something like "({!raw f=id}Ij7B63g-gSHA) OR ({!raw f=id}PBcGI3g-gSHA)" @@ -267,6 +279,10 @@ public class EmbeddedSolrConnector extends SolrServerConnector implements SolrCo } finally { docListSearcher.close(); } + long debugCollectionTime = System.currentTimeMillis() - start; + if (debug) { + ConcurrentLog.info("EmbeddedSolrConnector", "Comparisment of existsByIds: input=" + ids.size() + " records, output=" + idsr.size() + " records, singleTime=" + debugSingleTime + ", collectionTime=" + debugCollectionTime + ", singleCount=" + debugSingleCount + ", collectionCount=" + idsr.size()); + } // construct a new id list from that return idsr; }