[ 
https://issues.apache.org/jira/browse/SOLR-12878?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16673334#comment-16673334
 ] 

Tim Underwood commented on SOLR-12878:
--------------------------------------

There are 2 other LeafReader implementations not caching their FieldInfos:
 * org.apache.solr.search.CollapsingQParserPlugin.ReaderWrapper
 * org.apache.solr.handler.component.ExpandComponent.ReaderWrapper

Both have code that is basically this:
{code:java}
@SuppressWarnings("resource") LeafReader uninvertingReader = 
UninvertingReader.wrap(
    new ReaderWrapper(searcher.getSlowAtomicReader(), field),
    Collections.singletonMap(field, UninvertingReader.Type.SORTED)::get);
{code}
Note the searcher.getSlowAtomicReader() call which means moving the caching of 
FieldInfos into SlowCompositeReaderWrapper will help in this case!

Here is part of the code from UninvertingReader.wrap:
{code:java}
public static LeafReader wrap(LeafReader in, Function<String, Type> mapping) {
  boolean wrap = false;

  // Calculate a new FieldInfos that has DocValuesType where we didn't before
  ArrayList<FieldInfo> newFieldInfos = new 
ArrayList<>(in.getFieldInfos().size());
  for (FieldInfo fi : in.getFieldInfos()) {
    DocValuesType type = fi.getDocValuesType();
{code}
Note the 2 immediate calls to in.getFieldInfos().  So... I'll add the FieldInfo 
caching to both of those ReaderWrapper classes since it would help.

 

> FacetFieldProcessorByHashDV is reconstructing FieldInfos on every 
> instantiation
> -------------------------------------------------------------------------------
>
>                 Key: SOLR-12878
>                 URL: https://issues.apache.org/jira/browse/SOLR-12878
>             Project: Solr
>          Issue Type: Bug
>      Security Level: Public(Default Security Level. Issues are Public) 
>          Components: Facet Module
>    Affects Versions: 7.5
>            Reporter: Tim Underwood
>            Priority: Major
>              Labels: performance
>             Fix For: 7.6, master (8.0)
>
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> The FacetFieldProcessorByHashDV constructor is currently calling:
> {noformat}
> FieldInfo fieldInfo = 
> fcontext.searcher.getSlowAtomicReader().getFieldInfos().fieldInfo(sf.getName());
> {noformat}
> Which is reconstructing FieldInfos each time.  Simply switching it to:
> {noformat}
> FieldInfo fieldInfo = 
> fcontext.searcher.getFieldInfos().fieldInfo(sf.getName());
> {noformat}
>  
> causes it to use the cached version of FieldInfos in the SolrIndexSearcher.
> On my index the FacetFieldProcessorByHashDV is 2-3 times slower than the 
> legacy facets without this fix.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to