Apache Solr open-source search software
SOLR-666 -- Expose warmup time in statistics for SolrIndexSearcher and LRUCache
Shalin Shekhar Mangara18aea63f1dc
diff --git a/CHANGES.txt b/CHANGES.txtindex 4032d1c0e40..ed8f695356d 100644--- a/CHANGES.txt+++ b/CHANGES.txt@@ -327,6 +327,8 @@ New Features63. SOLR-256: Support exposing Solr statistics through JMX (Sharad Agrawal, shalin)+64. SOLR-666: Expose warmup time in statistics for SolrIndexSearcher and LRUCache (shalin)+Changes in runtime behavior1. SOLR-559: use Lucene updateDocument, deleteDocuments methods. Thisdiff --git a/src/java/org/apache/solr/search/LRUCache.java b/src/java/org/apache/solr/search/LRUCache.javaindex 36f5a648865..26e76a791f0 100644--- a/src/java/org/apache/solr/search/LRUCache.java+++ b/src/java/org/apache/solr/search/LRUCache.java@@ -52,6 +52,8 @@ public class LRUCache implements SolrCache {private long inserts;private long evictions;+ private long warmupTime = 0;+private Map map;private String name;private int autowarmCount;@@ -156,7 +158,7 @@ public class LRUCache implements SolrCache {public void warm(SolrIndexSearcher searcher, SolrCache old) throws IOException {if (regenerator==null) return;-+ long warmingStartTime = System.currentTimeMillis();LRUCache other = (LRUCache)old;// warm entries@@ -197,6 +199,8 @@ public class LRUCache implements SolrCache {}}}++ warmupTime = System.currentTimeMillis() - warmingStartTime;}@@ -262,6 +266,8 @@ public class LRUCache implements SolrCache {lst.add("size", map.size());}+ lst.add("warmupTime", warmupTime);+long clookups = stats.lookups.get();long chits = stats.hits.get();lst.add("cumulative_lookups", clookups);diff --git a/src/java/org/apache/solr/search/SolrIndexSearcher.java b/src/java/org/apache/solr/search/SolrIndexSearcher.javaindex 1655639153c..14480553315 100644--- a/src/java/org/apache/solr/search/SolrIndexSearcher.java+++ b/src/java/org/apache/solr/search/SolrIndexSearcher.java@@ -61,6 +61,7 @@ public class SolrIndexSearcher extends Searcher implements SolrInfoMBean {private final String name;private long openTime = System.currentTimeMillis();private long registerTime = 0;+ private long warmupTime = 0;private final IndexSearcher searcher;private final IndexReader reader;private final boolean closeReader;@@ -1510,13 +1511,14 @@ public class SolrIndexSearcher extends Searcher implements SolrInfoMBean {public void warm(SolrIndexSearcher old) throws IOException {// Make sure this is first! filters can help queryResults execute!boolean logme = log.isLoggable(Level.INFO);-+ long warmingStartTime = System.currentTimeMillis();// warm the caches in order...for (int i=0; i<cacheList.length; i++) {if (logme) log.info("autowarming " + this + " from " + old + "\n\t" + old.cacheList[i]);this.cacheList[i].warm(this, old.cacheList[i]);if (logme) log.info("autowarming result for " + this + "\n\t" + this.cacheList[i]);}+ warmupTime = System.currentTimeMillis() - warmingStartTime;}/**@@ -1589,6 +1591,7 @@ public class SolrIndexSearcher extends Searcher implements SolrInfoMBean {lst.add("indexVersion", reader.getVersion());lst.add("openedAt", new Date(openTime));if (registerTime!=0) lst.add("registeredAt", new Date(registerTime));+ lst.add("warmupTime", warmupTime);return lst;}