Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable caching when queries are profiled #48195

Merged
merged 5 commits into from
Nov 20, 2019

Conversation

jimczi
Copy link
Contributor

@jimczi jimczi commented Oct 17, 2019

This change disables the query and request cache when
profile is set to true in the request. This means that profiled queries
will not check caches to execute the query and the result will never be
added in the cache either.

Closes #33298

This change disables the query and request cache when
profile is set to true in the request. This means that profiled queries
will not check caches to execute the query and the result will never be
added in the cache either.

Closes elastic#33298
@jimczi jimczi added >enhancement :Search/Search Search-related issues that do not fall into other categories v8.0.0 v7.6.0 labels Oct 17, 2019
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search (:Search/Search)

Copy link
Contributor

@jpountz jpountz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One question.

if (profiler != null) {
// disable query caching on profiled query
setQueryCachingPolicy(NEVER_CACHE_POLICY);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

out of curiosity, why isn't returning false on ProfileWeight enough?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the sub-query might be cacheable so returning false only ensures that we don't cache the query at the profile weight level. Sub queries are still eligible for caching so we have to disable caching entirely.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought we wrapped sub weights too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do and that works for intermediate level but leaves are still eligible for caching so a simple range query could get cached ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't the range weight be wrapped as well?

@jpountz
Copy link
Contributor

jpountz commented Oct 29, 2019

I looked a bit more into this and maybe we could simplify by creating the weight manually instead of using IndexSearcher, i.e. replacing the call to super.createWeight(query, scoreMode, boost) with query.creatWeight(this, scoreMode, boost) in ContextIndexSearcher?

@jimczi
Copy link
Contributor Author

jimczi commented Oct 29, 2019

Thanks for looking @jpountz . I pushed e88b7fd to simplify the logic as suggested.

@jimczi jimczi merged commit 15023ba into elastic:master Nov 20, 2019
@jimczi jimczi deleted the query_profile_no_cache branch November 20, 2019 14:33
jimczi added a commit that referenced this pull request Nov 20, 2019
This change disables the query and request cache when
profile is set to true in the request. This means that profiled queries
will not check caches to execute the query and the result will never be
added in the cache either.

Closes #33298
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>enhancement :Search/Search Search-related issues that do not fall into other categories v7.6.0 v8.0.0-alpha1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Disable cache when profiling requests
4 participants