You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Uwe Schindler (JIRA)" <ji...@apache.org> on 2017/10/23 20:29:00 UTC

[jira] [Commented] (LUCENE-8005) Avoid Class.getSimpleName in UsageTrackingQueryCachingPolicy

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

Uwe Schindler commented on LUCENE-8005:
---------------------------------------

IMHO, the current code looks horrible. On the other hand, I agree with Robert that adding a superclass makes no sense as there is no funtionality to share. Maybe we will refactor some subclasses to use another query type. How about adding a marker interface and doing instance of check on it?

I don't like the current code as it is not type safe. What happens if you create a new point query without "point" in the name? Or if you have your own class with a name like this? The full class name, as suggested by Robert, does not help with that, it just improves performance of the buggy check.

> Avoid Class.getSimpleName in UsageTrackingQueryCachingPolicy
> ------------------------------------------------------------
>
>                 Key: LUCENE-8005
>                 URL: https://issues.apache.org/jira/browse/LUCENE-8005
>             Project: Lucene - Core
>          Issue Type: Improvement
>            Reporter: Scott Somerville
>         Attachments: LUCENE-8005.patch, LUCENE-8005.patch
>
>
> By profiling an Elasticsearch cluster, I found the private method UsageTrackingQueryCachingPolicy.isPointQuery to be quite expensive due to the clazz.getSimpleName() call.
> Here is an excerpt from hot_threads:
> {noformat}
> java.lang.Class.getEnclosingMethod0(Native Method)
>        java.lang.Class.getEnclosingMethodInfo(Class.java:1072)
>        java.lang.Class.getEnclosingClass(Class.java:1272)
>        java.lang.Class.getSimpleBinaryName(Class.java:1443)
>        java.lang.Class.getSimpleName(Class.java:1309)
>        org.apache.lucene.search.UsageTrackingQueryCachingPolicy.isPointQuery(UsageTrackingQueryCachingPolicy.java:39)
>        org.apache.lucene.search.UsageTrackingQueryCachingPolicy.isCostly(UsageTrackingQueryCachingPolicy.java:54)
>        org.apache.lucene.search.UsageTrackingQueryCachingPolicy.minFrequencyToCache(UsageTrackingQueryCachingPolicy.java:121)
>        org.apache.lucene.search.UsageTrackingQueryCachingPolicy.shouldCache(UsageTrackingQueryCachingPolicy.java:179)
>        org.elasticsearch.index.shard.ElasticsearchQueryCachingPolicy.shouldCache(ElasticsearchQueryCachingPolicy.java:53)
>        org.apache.lucene.search.LRUQueryCache$CachingWrapperWeight.bulkScorer(LRUQueryCache.java:806)
>        org.elasticsearch.indices.IndicesQueryCache$CachingWeightWrapper.bulkScorer(IndicesQueryCache.java:168)
>        org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:665)
>        org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:472)
>        org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:388)
>        org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:108)
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org