mirror of https://github.com/apache/lucene.git
SOLR-9844: Improve FieldCache usage api response formatting and show total size information
This commit is contained in:
parent
87d8b5450a
commit
39ba13046b
|
@ -56,6 +56,7 @@ final class SegmentCoreReaders {
|
||||||
final TermVectorsReader termVectorsReaderOrig;
|
final TermVectorsReader termVectorsReaderOrig;
|
||||||
final PointsReader pointsReader;
|
final PointsReader pointsReader;
|
||||||
final Directory cfsReader;
|
final Directory cfsReader;
|
||||||
|
final String segment;
|
||||||
/**
|
/**
|
||||||
* fieldinfos for this core: means gen=-1.
|
* fieldinfos for this core: means gen=-1.
|
||||||
* this is the exact fieldinfos these codec components saw at write.
|
* this is the exact fieldinfos these codec components saw at write.
|
||||||
|
@ -98,6 +99,8 @@ final class SegmentCoreReaders {
|
||||||
cfsDir = dir;
|
cfsDir = dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
segment = si.info.name;
|
||||||
|
|
||||||
coreFieldInfos = codec.fieldInfosFormat().read(cfsDir, si.info, "", context);
|
coreFieldInfos = codec.fieldInfosFormat().read(cfsDir, si.info, "", context);
|
||||||
|
|
||||||
final SegmentReadState segmentReadState = new SegmentReadState(cfsDir, si.info, coreFieldInfos, context);
|
final SegmentReadState segmentReadState = new SegmentReadState(cfsDir, si.info, coreFieldInfos, context);
|
||||||
|
@ -192,4 +195,9 @@ final class SegmentCoreReaders {
|
||||||
void removeCoreClosedListener(CoreClosedListener listener) {
|
void removeCoreClosedListener(CoreClosedListener listener) {
|
||||||
coreClosedListeners.remove(listener);
|
coreClosedListeners.remove(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "SegmentCoreReader(" + segment + ")";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -164,6 +164,9 @@ New Features
|
||||||
* SOLR-5043: New solr.dns.prevent.reverse.lookup system property that can be used to prevent long core
|
* 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)
|
(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
|
Optimizations
|
||||||
----------------------
|
----------------------
|
||||||
* SOLR-9704: Facet Module / JSON Facet API: Optimize blockChildren facets that have
|
* SOLR-9704: Facet Module / JSON Facet API: Optimize blockChildren facets that have
|
||||||
|
|
|
@ -64,11 +64,13 @@ public class SolrFieldCacheMBean implements JmxAugmentedSolrInfoMBean {
|
||||||
if (listEntries) {
|
if (listEntries) {
|
||||||
String[] entries = UninvertingReader.getUninvertedStats();
|
String[] entries = UninvertingReader.getUninvertedStats();
|
||||||
stats.add("entries_count", entries.length);
|
stats.add("entries_count", entries.length);
|
||||||
|
stats.add("total_size", UninvertingReader.getTotalSize());
|
||||||
for (int i = 0; i < entries.length; i++) {
|
for (int i = 0; i < entries.length; i++) {
|
||||||
stats.add("entry#" + i, entries[i]);
|
stats.add("entry#" + i, entries[i]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
stats.add("entries_count", UninvertingReader.getUninvertedStatsSize());
|
stats.add("entries_count", UninvertingReader.getUninvertedStatsSize());
|
||||||
|
stats.add("total_size", UninvertingReader.getTotalSize());
|
||||||
}
|
}
|
||||||
return stats;
|
return stats;
|
||||||
}
|
}
|
||||||
|
|
|
@ -384,7 +384,7 @@ public interface FieldCache {
|
||||||
return custom;
|
return custom;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object getValue() {
|
public Accountable getValue() {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -399,15 +399,11 @@ public interface FieldCache {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuilder b = new StringBuilder(250);
|
StringBuilder b = new StringBuilder(100);
|
||||||
b.append("'").append(getReaderKey()).append("'=>");
|
b.append("segment='").append(getReaderKey().toString()).append("', ");
|
||||||
b.append("'").append(getFieldName()).append("',");
|
b.append("field='").append(getFieldName()).append("', ");
|
||||||
b.append(getCacheType()).append(",").append(getCustom());
|
|
||||||
b.append("=>").append(getValue().getClass().getName()).append("#");
|
|
||||||
b.append(System.identityHashCode(getValue()));
|
|
||||||
|
|
||||||
String s = getEstimatedSize();
|
String s = getEstimatedSize();
|
||||||
b.append(" (size =~ ").append(s).append(')');
|
b.append("size =~ ").append(s);
|
||||||
|
|
||||||
return b.toString();
|
return b.toString();
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ import java.util.Set;
|
||||||
import org.apache.lucene.index.IndexReader;
|
import org.apache.lucene.index.IndexReader;
|
||||||
import org.apache.lucene.index.IndexReaderContext;
|
import org.apache.lucene.index.IndexReaderContext;
|
||||||
import org.apache.lucene.store.AlreadyClosedException;
|
import org.apache.lucene.store.AlreadyClosedException;
|
||||||
|
import org.apache.lucene.util.Accountable;
|
||||||
import org.apache.lucene.util.MapOfSets;
|
import org.apache.lucene.util.MapOfSets;
|
||||||
import org.apache.solr.uninverting.FieldCache.CacheEntry;
|
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
|
// iterate over all the cacheEntries to get the mappings we'll need
|
||||||
for (int i = 0; i < cacheEntries.length; i++) {
|
for (int i = 0; i < cacheEntries.length; i++) {
|
||||||
final CacheEntry item = cacheEntries[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
|
// It's OK to have dup entries, where one is eg
|
||||||
// float[] and the other is the Bits (from
|
// float[] and the other is the Bits (from
|
||||||
|
|
|
@ -37,6 +37,7 @@ import org.apache.lucene.index.LeafReader;
|
||||||
import org.apache.lucene.index.NumericDocValues;
|
import org.apache.lucene.index.NumericDocValues;
|
||||||
import org.apache.lucene.index.SortedDocValues;
|
import org.apache.lucene.index.SortedDocValues;
|
||||||
import org.apache.lucene.index.SortedSetDocValues;
|
import org.apache.lucene.index.SortedSetDocValues;
|
||||||
|
import org.apache.lucene.util.RamUsageEstimator;
|
||||||
import org.apache.solr.uninverting.FieldCache.CacheEntry;
|
import org.apache.solr.uninverting.FieldCache.CacheEntry;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -386,4 +387,13 @@ public class UninvertingReader extends FilterLeafReader {
|
||||||
public static int getUninvertedStatsSize() {
|
public static int getUninvertedStatsSize() {
|
||||||
return FieldCache.DEFAULT.getCacheEntries().length;
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,6 +76,7 @@ public class TestSolrFieldCacheMBean extends SolrTestCaseJ4 {
|
||||||
SolrFieldCacheMBean mbean = new SolrFieldCacheMBean();
|
SolrFieldCacheMBean mbean = new SolrFieldCacheMBean();
|
||||||
NamedList stats = checkJmx ? mbean.getStatisticsForJmx() : mbean.getStatistics();
|
NamedList stats = checkJmx ? mbean.getStatisticsForJmx() : mbean.getStatistics();
|
||||||
assert(new Integer(stats.get("entries_count").toString()) > 0);
|
assert(new Integer(stats.get("entries_count").toString()) > 0);
|
||||||
|
assertNotNull(stats.get("total_size"));
|
||||||
assertNull(stats.get("entry#0"));
|
assertNull(stats.get("entry#0"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue