SOLR-9844: Improve FieldCache usage api response formatting and show total size information

This commit is contained in:
Varun Thacker 2016-12-12 12:38:14 -08:00
parent 87d8b5450a
commit 39ba13046b
7 changed files with 31 additions and 10 deletions

View File

@ -56,6 +56,7 @@ final class SegmentCoreReaders {
final TermVectorsReader termVectorsReaderOrig;
final PointsReader pointsReader;
final Directory cfsReader;
final String segment;
/**
* fieldinfos for this core: means gen=-1.
* this is the exact fieldinfos these codec components saw at write.
@ -98,6 +99,8 @@ final class SegmentCoreReaders {
cfsDir = dir;
}
segment = si.info.name;
coreFieldInfos = codec.fieldInfosFormat().read(cfsDir, si.info, "", context);
final SegmentReadState segmentReadState = new SegmentReadState(cfsDir, si.info, coreFieldInfos, context);
@ -192,4 +195,9 @@ final class SegmentCoreReaders {
void removeCoreClosedListener(CoreClosedListener listener) {
coreClosedListeners.remove(listener);
}
@Override
public String toString() {
return "SegmentCoreReader(" + segment + ")";
}
}

View File

@ -164,6 +164,9 @@ New Features
* SOLR-5043: New solr.dns.prevent.reverse.lookup system property that can be used to prevent long core
(re)load delays on systems with missconfigured hostname/DNS (hossman)
* SOLR-9844: FieldCache information fetched via the mbeans handler or seen via the UI now displays the total size used.
The individual cache entries in the response are now formatted better as well. (Varun Thacker)
Optimizations
----------------------
* SOLR-9704: Facet Module / JSON Facet API: Optimize blockChildren facets that have

View File

@ -64,11 +64,13 @@ public class SolrFieldCacheMBean implements JmxAugmentedSolrInfoMBean {
if (listEntries) {
String[] entries = UninvertingReader.getUninvertedStats();
stats.add("entries_count", entries.length);
stats.add("total_size", UninvertingReader.getTotalSize());
for (int i = 0; i < entries.length; i++) {
stats.add("entry#" + i, entries[i]);
}
} else {
stats.add("entries_count", UninvertingReader.getUninvertedStatsSize());
stats.add("total_size", UninvertingReader.getTotalSize());
}
return stats;
}

View File

@ -384,7 +384,7 @@ public interface FieldCache {
return custom;
}
public Object getValue() {
public Accountable getValue() {
return value;
}
@ -399,15 +399,11 @@ public interface FieldCache {
@Override
public String toString() {
StringBuilder b = new StringBuilder(250);
b.append("'").append(getReaderKey()).append("'=>");
b.append("'").append(getFieldName()).append("',");
b.append(getCacheType()).append(",").append(getCustom());
b.append("=>").append(getValue().getClass().getName()).append("#");
b.append(System.identityHashCode(getValue()));
StringBuilder b = new StringBuilder(100);
b.append("segment='").append(getReaderKey().toString()).append("', ");
b.append("field='").append(getFieldName()).append("', ");
String s = getEstimatedSize();
b.append(" (size =~ ").append(s).append(')');
b.append("size =~ ").append(s);
return b.toString();
}

View File

@ -27,6 +27,7 @@ import java.util.Set;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexReaderContext;
import org.apache.lucene.store.AlreadyClosedException;
import org.apache.lucene.util.Accountable;
import org.apache.lucene.util.MapOfSets;
import org.apache.solr.uninverting.FieldCache.CacheEntry;
@ -103,7 +104,7 @@ final class FieldCacheSanityChecker {
// iterate over all the cacheEntries to get the mappings we'll need
for (int i = 0; i < cacheEntries.length; i++) {
final CacheEntry item = cacheEntries[i];
final Object val = item.getValue();
final Accountable val = item.getValue();
// It's OK to have dup entries, where one is eg
// float[] and the other is the Bits (from

View File

@ -37,6 +37,7 @@ import org.apache.lucene.index.LeafReader;
import org.apache.lucene.index.NumericDocValues;
import org.apache.lucene.index.SortedDocValues;
import org.apache.lucene.index.SortedSetDocValues;
import org.apache.lucene.util.RamUsageEstimator;
import org.apache.solr.uninverting.FieldCache.CacheEntry;
/**
@ -386,4 +387,13 @@ public class UninvertingReader extends FilterLeafReader {
public static int getUninvertedStatsSize() {
return FieldCache.DEFAULT.getCacheEntries().length;
}
public static String getTotalSize() {
CacheEntry[] entries = FieldCache.DEFAULT.getCacheEntries();
long totalBytesUsed = 0;
for (int i = 0; i < entries.length; i++) {
totalBytesUsed += entries[i].getValue().ramBytesUsed();
}
return RamUsageEstimator.humanReadableUnits(totalBytesUsed);
}
}

View File

@ -76,6 +76,7 @@ public class TestSolrFieldCacheMBean extends SolrTestCaseJ4 {
SolrFieldCacheMBean mbean = new SolrFieldCacheMBean();
NamedList stats = checkJmx ? mbean.getStatisticsForJmx() : mbean.getStatistics();
assert(new Integer(stats.get("entries_count").toString()) > 0);
assertNotNull(stats.get("total_size"));
assertNull(stats.get("entry#0"));
}
}