Skip to content

Reduce performance impact of ExitableDirectoryReader #53978

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

Merged
merged 3 commits into from
Mar 23, 2020

Conversation

matriv
Copy link
Contributor

@matriv matriv commented Mar 23, 2020

Benchmarking showed that the effect of the ExitableDirectoryReader
is reduced considerably when checking every 8191 docs. Moreover,
set the cancellable task before calling QueryPhase#preProcess()
and make sure we don't wrap with an ExitableDirectoryReader at all
when lowLevelCancellation is set to false to avoid completely any
performance impact.

Follows: #52822
Follows: #53166
Follows: #53496

@matriv matriv added :Search/Search Search-related issues that do not fall into other categories v8.0.0 v7.7.0 labels Mar 23, 2020
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search (:Search/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.

I left two comments

@@ -276,7 +276,7 @@ public void visit(int docID, byte[] packedValue) throws IOException {

@Override
public PointValues.Relation compare(byte[] minPackedValue, byte[] maxPackedValue) {
queryCancellation.checkCancelled();
checkAndThrowWithSampling();
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we should throttle this. We don't have enough evidence that it's slowing down the request so I'd keep it as is for now.

this(reader, similarity, queryCache, queryCachingPolicy, new MutableQueryTimeout());
QueryCache queryCache, QueryCachingPolicy queryCachingPolicy,
boolean wrapWithExitableDirReader) throws IOException {
this(reader, similarity, queryCache, queryCachingPolicy, wrapWithExitableDirReader ? new MutableQueryTimeout() : null);
Copy link
Contributor

Choose a reason for hiding this comment

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

We use the cancellable even if the low level cancellation is set to false (query timeout option and bulk scorer) so we should never set the cancellable to null ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, sure, I just pushed it to check some other compilation stuff. it's not ready yet, but thx!

Benchmarking showed that the effect of the ExitableDirectoryReader
is reduced considerably when checking every 4095 docs. Moreover,
set the cancellable task before calling QueryPhase.preProcess()
and make sure we don't wrap with an ExitableDirectoryReader at all
when lowLevelCancellation() is set to false to avoid completely any
performance impact.

Follows: elastic#52822
Follows: elastic#53166
Follows: elastic#53496
@matriv matriv force-pushed the fix-perf-exitable branch from 701af61 to 8f23bc7 Compare March 23, 2020 16:35
@matriv
Copy link
Contributor Author

matriv commented Mar 23, 2020

Benchmark results:
Every 15 docs against before the ExitableDirectoryReader:

| 50th percentile latency       | range | 583.245 | 812.253 | 229.008 | ms
| 90th percentile latency       | range | 611.570 | 829.862 | 218.293 | ms
| 99th percentile latency       | range | 654.343 | 834.233 | 179.890 | ms
| 100th percentile latency      | range | 680.618 | 834.705 | 154.087 | ms
| 50th percentile service time  | range | 582.807 | 812.057 | 229.250 | ms
| 90th percentile service time  | range | 611.161 | 829.650 | 218.489 | ms
| 99th percentile service time  | range | 653.917 | 834.020 | 180.103 | ms
| 100th percentile service time | range | 680.173 | 834.498 | 154.325 | ms

Every 511 docs against before the ExitableDirectoryReader:

| 50th percentile latency       | range | 583.245 | 680.821 | 97.5762 | ms 
| 90th percentile latency       | range | 611.570 | 685.779 | 74.2091 | ms 
| 99th percentile latency       | range | 654.343 | 703.391 | 49.0486 | ms 
| 100th percentile latency      | range | 680.618 | 705.311 | 24.6928 | ms 
| 50th percentile service time  | range | 582.807 | 680.471 | 97.6644 | ms 
| 90th percentile service time  | range | 611.161 | 685.436 | 74.2750 | ms 
| 99th percentile service time  | range | 653.917 | 703.029 | 49.1121 | ms 
| 100th percentile service time | range | 680.173 | 704.956 | 24.7833 | ms 

Every 1023 docs against before the ExitableDirectoryReader:

| 50th percentile latency       | range | 583.245 | 664.071 | 80.8259 |ms 
| 90th percentile latency       | range | 611.57o | 689.781 | 78.2116 |ms 
| 99th percentile latency       | range | 654.343 | 704.416 | 50.0736 |ms 
| 100th percentile latency      | range | 680.618 | 708.995 | 28.3769 |ms 
| 50th percentile service time  | range | 582.807 | 663.713 | 80.9063 |ms 
| 90th percentile service time  | range | 611.161 | 689.454 | 78.2930 |ms 
| 99th percentile service time  | range | 653.917 | 704.062 | 50.1454 |ms 
| 100th percentile service time | range | 680.173 | 708.615 | 28.4416 |ms 

Every 2047 docs against before the ExitableDirectoryReader:

| 50th percentile latency       | range | 583.245 | 689.420 | 106.1750 | ms 
| 90th percentile latency       | range | 611.570 | 696.340 |  84.7710 | ms 
| 99th percentile latency       | range | 654.343 | 713.150 |  58.8076 | ms 
| 100th percentile latency      | range | 680.618 | 716.831 |  36.2128 | ms 
| 50th percentile service time  | range | 582.807 | 689.080 | 106.2730 | ms 
| 90th percentile service time  | range | 611.161 | 695.992 |  84.8309 | ms 
| 99th percentile service time  | range | 653.917 | 712.807 |  58.8900 | ms 
| 100th percentile service time | range | 680.173 | 716.489 |  36.3162 | ms 

Every 4095 docs against before the ExitableDirectoryReader:

| 50th percentile latency       | range | 583.245 | 684.115 | 100.8700 | ms 
| 90th percentile latency       | range | 611.570 | 691.236 |  79.6661 | ms 
| 99th percentile latency       | range | 654.343 | 706.371 |  52.0284 | ms 
| 100th percentile latency      | range | 680.618 | 706.491 |  25.8729 | ms 
| 50th percentile service time  | range | 582.807 | 683.765 | 100.9590 | ms 
| 90th percentile service time  | range | 611.161 | 690.901 |  79.7403 | ms 
| 99th percentile service time  | range | 653.917 | 706.024 |  52.1079 | ms 
| 100th percentile service time | range | 680.173 | 706.151 |  25.9778 | ms 

Every 8191 docs against before the ExitableDirectoryReader:

| 50th percentile latency       | range | 583.245 | 600.239 |  16.99400 | ms 
| 90th percentile latency       | range | 611.570 | 601.961 |  -9.60834 | ms 
| 99th percentile latency       | range | 654.343 | 620.223 | -34.12030 | ms 
| 100th percentile latency      | range | 680.618 | 620.570 | -60.04800 | ms 
| 50th percentile service time  | range | 582.807 | 599.817 |  17.01030 | ms 
| 90th percentile service time  | range | 611.161 | 601.534 |  -9.62665 | ms 
| 99th percentile service time  | range | 653.917 | 619.786 | -34.13000 | ms 
| 100th percentile service time | range | 680.173 | 620.138 | -60.03540 | ms 

@matriv matriv requested review from jpountz and jimczi March 23, 2020 16:55
@matriv
Copy link
Contributor Author

matriv commented Mar 23, 2020

I'm leaning towards 8191 instead of 4095 (current status in the PR).

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.

LGTM, let's use 2^13 to be on the safe side. We can revise later if need to.

@matriv matriv merged commit cdc377e into elastic:master Mar 23, 2020
@matriv matriv deleted the fix-perf-exitable branch March 23, 2020 18:49
matriv added a commit that referenced this pull request Mar 23, 2020
Benchmarking showed that the effect of the ExitableDirectoryReader
is reduced considerably when checking every 8191 docs. Moreover,
set the cancellable task before calling QueryPhase#preProcess()
and make sure we don't wrap with an ExitableDirectoryReader at all
when lowLevelCancellation is set to false to avoid completely any
performance impact.

Follows: #52822
Follows: #53166
Follows: #53496

(cherry picked from commit cdc377e)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Search/Search Search-related issues that do not fall into other categories v7.7.0 v8.0.0-alpha1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants