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

Automatically adjust pre_filter_shard_size to 1 for readonly indices #43377

Conversation

javanna
Copy link
Member

@javanna javanna commented Jun 19, 2019

Now that we split the search execution in two whenever searching read-only and
write indices as part of the same request (see #42510), we can also automatically
set pre_filter_shard_size to the appropriate value whenever not explicitly
provided: 1 for readonly indices, and 128 (like before this change) for write
indices.

Note that we may still end up searching write and readonly indices as part of the
same search execution, for instance when a scroll is provided or size is set to 0,
in which case we set pre_filter_shard_size to 128 when not explicitly set.

Open questions:

  • this is a change in behaviour when pre_filter_shard_size is not set: it is not disruptive, yet
    does it deserve an entry in the migrate guide? If so we may want to discuss whether we can
    backport this change or not to 7.x.
  • I am not too happy with the exception that we only apply 1 if we are searching read-only indices alone, or if we are splitting the search execution. There are cases (for instance when size is set to 0) where we don't split the search execution, yet readonly indices will be searched as part of the same execution as write indices, in which case they will get 128 as a default value. Maybe we would like to apply the setting at a lower level so that when size is 0 we still apply 1 to read-only indices?

Closes #39835

Now that we split the search execution in two whenever searching read-only and
write indices as part of the same request (see elastic#42510), we can also automatically
set `pre_filter_shard_size` to the appropriate value whenever not explicitly
provided: `1` for readonly indices, and `128` (like before this change) for write
indices.

Note that we may still end up searching write and readonly indices as part of the
same search execution, for instance when a scroll is provided or size is set to `0`,
in which case we set `pre_filter_shard_size` to `128` when not explicitly set.

Closes elastic#39835
@javanna javanna added >enhancement :Search/Search Search-related issues that do not fall into other categories v8.0.0 v7.3.0 labels Jun 19, 2019
@javanna javanna requested a review from jimczi June 19, 2019 15:22
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search

Copy link
Contributor

@jimczi jimczi left a comment

Choose a reason for hiding this comment

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

Thanks @javanna.
I left one comment regarding the default value. Feel free to ignore and merge if you disagree.

The default value for `pre_filter_shard_size` is `128` but it's recommended to set it to `1` when searching frozen indices. There is no
significant overhead associated with this pre-filter phase.
a threshold that, when exceeded, will enforce a round-trip to pre-filter search shards that cannot possibly match. Whenever not explicitly
set, the parameter is automatically adjusted to `1` for read-only indices, and to `128 for write indices. This filter phase can limit the
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: missing "`" after 128.

Copy link
Member Author

Choose a reason for hiding this comment

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

good catch

@@ -60,7 +60,7 @@

private static final ToXContent.Params FORMAT_PARAMS = new ToXContent.MapParams(Collections.singletonMap("pretty", "false"));

public static final int DEFAULT_PRE_FILTER_SHARD_SIZE = 128;
public static final int DEFAULT_PRE_FILTER_SHARD_SIZE = -1;
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: we serialize this value using read/writeVInt so -1 is not a very good default since it will always use 5 bytes. This shouldn't affect anything but we also disallow setting this value to a negative number explicitly in SearchRequest so it will not be possible for users to restore the default value in a SearchRequest. I wonder if it would be simpler to use an Integer and readOptionaVInt to make the intent clear ?

Copy link
Member Author

Choose a reason for hiding this comment

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

good point: I follow the bytes reasoning more than the resetting issue, cause generally we do not allow null values either when validating requests, hence you need to create a new request to go back to the default values. I am not a big fan of null values, so I have a slight preference for -1 but I can also change that

@javanna
Copy link
Member Author

javanna commented Jun 20, 2019

run elasticsearch-ci/1

@timroes
Copy link
Contributor

timroes commented Dec 13, 2019

Hi @javanna,

could you please give a quick update on what's the status of this PR?

Also to one of your questions above:

I am not too happy with the exception that we only apply 1 if we are searching read-only indices alone, or if we are splitting the search execution. There are cases (for instance when size is set to 0) where we don't split the search execution, yet readonly indices will be searched as part of the same execution as write indices, in which case they will get 128 as a default value. Maybe we would like to apply the setting at a lower level so that when size is 0 we still apply 1 to read-only indices?

I would totally support that suggestion of moving this to a lower level. Kibana uses size: 0 queries for all visualizations, and it would be awesome if we would have that performance gain also for visualizations, not just for discover when we're loading pure documents.

@polyfractal polyfractal added v7.7.0 and removed v7.6.0 labels Jan 15, 2020
@javanna
Copy link
Member Author

javanna commented Feb 18, 2020

heya @timroes as for the status of this PR, it has stalled because we were not too happy with the limitations it has. We were discussing as an alternative to potentially apply 1 and force the execution of the can_match phase for every search no matter which indices it executes against. I need to sync with the team on where we stand with that change. In the meantime I will close this PR as it will not go in as-is for the reason stated above.

@javanna javanna closed this Feb 18, 2020
@javanna
Copy link
Member Author

javanna commented Feb 21, 2020

Some more context: we no longer split the execution in two when readonly and non-readonly indices are searched at the same time (see #49471), hence this change is not even possible at this level, yet another reason to close this PR and consider a different approach.

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Change pre_filter_shard_size default to 1 for frozen index searches
7 participants