Skip to content

Use sequential access of stored fields in CCR #68961

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 4 commits into from
Feb 16, 2021

Conversation

dnhatn
Copy link
Member

@dnhatn dnhatn commented Feb 13, 2021

This commit re-introduces the sequential access of stored fields in CCR. Unlike the previous change, we apply this optimization only when we are accessing 10+ consecutive document ids.

I ran a CCR benchmark, and this change increased the indexing throughput on the leader by 30%.

@dnhatn dnhatn force-pushed the ccr-optimize-stored-fields branch 3 times, most recently from e7ae7e4 to 3d2dcde Compare February 15, 2021 22:05
@dnhatn dnhatn force-pushed the ccr-optimize-stored-fields branch from 3d2dcde to 68053ef Compare February 15, 2021 22:06
@dnhatn
Copy link
Member Author

dnhatn commented Feb 16, 2021

Below is a benchmark from eventdata dataset (append-no-conflicts challenge).

                                                       Metric |    Baseline |   Contender |     Diff |   Unit
-------------------------------------------------------------:|------------:|------------:|---------:|-------
                   Cumulative indexing time of primary shards |     105.252 |     72.2137 | -33.0379 |    min
            Min cumulative indexing time across primary shard |     20.5952 |      14.192 | -6.40315 |    min
         Median cumulative indexing time across primary shard |     21.0276 |     14.4028 | -6.62472 |    min
            Max cumulative indexing time across primary shard |     21.3481 |     14.6981 | -6.65002 |    min
          Cumulative indexing throttle time of primary shards |           0 |           0 |        0 |    min
   Min cumulative indexing throttle time across primary shard |           0 |           0 |        0 |    min
Median cumulative indexing throttle time across primary shard |           0 |           0 |        0 |    min
   Max cumulative indexing throttle time across primary shard |           0 |           0 |        0 |    min
                      Cumulative merge time of primary shards |     7.17612 |      85.695 |  78.5189 |    min
                     Cumulative merge count of primary shards |           8 |        2299 |     2291 |       
               Min cumulative merge time across primary shard |   0.0409833 |     16.5366 |  16.4956 |    min
            Median cumulative merge time across primary shard |     2.19387 |     17.0846 |  14.8908 |    min
               Max cumulative merge time across primary shard |     2.60822 |     17.7988 |  15.1906 |    min
             Cumulative merge throttle time of primary shards |     1.16685 |     4.76085 |    3.594 |    min
      Min cumulative merge throttle time across primary shard |           0 |    0.599183 |  0.59918 |    min
   Median cumulative merge throttle time across primary shard |     0.35825 |     0.68505 |   0.3268 |    min
      Max cumulative merge throttle time across primary shard |    0.415783 |     1.56858 |   1.1528 |    min
                    Cumulative refresh time of primary shards |     2.22127 |     33.6916 |  31.4704 |    min
                   Cumulative refresh count of primary shards |          81 |       20283 |    20202 |       
             Min cumulative refresh time across primary shard |    0.318417 |     6.66377 |  6.34535 |    min
          Median cumulative refresh time across primary shard |    0.437233 |     6.72832 |  6.29108 |    min
             Max cumulative refresh time across primary shard |    0.553483 |     6.84258 |   6.2891 |    min
                      Cumulative flush time of primary shards |     11.5855 |    0.503367 | -11.0822 |    min
                     Cumulative flush count of primary shards |          31 |          30 |       -1 |       
               Min cumulative flush time across primary shard |      1.9158 |   0.0930833 | -1.82272 |    min
            Median cumulative flush time across primary shard |     2.27915 |      0.0968 | -2.18235 |    min
               Max cumulative flush time across primary shard |      2.9223 |      0.1139 |  -2.8084 |    min
                                      Total Young Gen GC time |      38.794 |       5.519 |  -33.275 |      s
                                     Total Young Gen GC count |        1534 |         220 |    -1314 |       
                                        Total Old Gen GC time |           0 |           0 |        0 |      s
                                       Total Old Gen GC count |           0 |           0 |        0 |       
                                                   Store size |     5.80673 |     5.84045 |  0.03372 |     GB
                                                Translog size | 2.56114e-07 | 2.56114e-07 |        0 |     GB
                                       Heap used for segments |    0.613789 |    0.642971 |  0.02918 |     MB
                                     Heap used for doc values |   0.0842857 |   0.0664864 |  -0.0178 |     MB
                                          Heap used for terms |    0.451263 |    0.490997 |  0.03973 |     MB
                                          Heap used for norms |           0 |           0 |        0 |     MB
                                         Heap used for points |           0 |           0 |        0 |     MB
                                  Heap used for stored fields |   0.0782394 |   0.0854874 |  0.00725 |     MB
                                                Segment count |         159 |         173 |       14 |       
                                               Min Throughput |     10617.9 |     12356.9 |     1739 | docs/s
                                              Mean Throughput |     11439.8 |     15415.8 |  3975.98 | docs/s
                                            Median Throughput |     11465.1 |     15678.8 |   4213.7 | docs/s
                                               Max Throughput |     11703.4 |     16059.6 |  4356.13 | docs/s
                                      50th percentile latency |      3163.5 |     2352.58 | -810.925 |     ms
                                      90th percentile latency |     3954.71 |     2734.01 |  -1220.7 |     ms
                                      99th percentile latency |     6229.13 |      4212.4 | -2016.74 |     ms
                                    99.9th percentile latency |     27692.5 |     7813.23 | -19879.3 |     ms
                                     100th percentile latency |     36693.7 |     8577.53 | -28116.2 |     ms
                                 50th percentile service time |      3163.5 |     2352.58 | -810.925 |     ms
                                 90th percentile service time |     3954.71 |     2734.01 |  -1220.7 |     ms
                                 99th percentile service time |     6229.13 |      4212.4 | -2016.74 |     ms
                               99.9th percentile service time |     27692.5 |     7813.23 | -19879.3 |     ms
                                100th percentile service time |     36693.7 |     8577.53 | -28116.2 |     ms
                                                   error rate |           0 |           0 |        0 |      %

@dnhatn dnhatn requested review from jimczi and romseygeek February 16, 2021 02:10
@dnhatn dnhatn added :Distributed Indexing/CCR Issues around the Cross Cluster State Replication features >enhancement v7.12.0 v8.0.0 labels Feb 16, 2021
@dnhatn dnhatn marked this pull request as ready for review February 16, 2021 02:11
@elasticmachine elasticmachine added the Team:Distributed (Obsolete) Meta label for distributed team (obsolete). Replaced by Distributed Indexing/Coordination. label Feb 16, 2021
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-distributed (Team:Distributed)

}
assertFalse(snapshot.useSequentialStoredFieldsReader());
}
// disable optimization for non-sequential accesses
Copy link
Contributor

Choose a reason for hiding this comment

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

This comment doesn't seem to correspond with the test below?

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. I fixed in 3eb853d.

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 one comment, LGTM otherwise

}
}

private static boolean hasSequentialAccess(ScoreDoc[] scoreDocs) {
Copy link
Contributor

Choose a reason for hiding this comment

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

You can avoid the loop entirely like in FetchPhase#hasSequentialDocs

Copy link
Member Author

@dnhatn dnhatn Feb 16, 2021

Choose a reason for hiding this comment

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

This is a bit different. We can access documents out of order instead of ascending like in the fetch phase.

@dnhatn dnhatn requested a review from romseygeek February 16, 2021 16:09
@dnhatn
Copy link
Member Author

dnhatn commented Feb 16, 2021

run elasticsearch-ci/2

@dnhatn
Copy link
Member Author

dnhatn commented Feb 16, 2021

@romseygeek @jimczi Thanks for review.

@dnhatn dnhatn merged commit dad0aea into elastic:master Feb 16, 2021
@dnhatn dnhatn deleted the ccr-optimize-stored-fields branch February 16, 2021 17:57
dnhatn added a commit that referenced this pull request Feb 16, 2021
This commit re-introduces the sequential access of stored fields in CCR.
Unlike the previous change, we apply this optimization only when we are
accessing 10+ consecutive document ids.

I ran a CCR benchmark, and this change increased the indexing throughput
on the leader by 30%.
dnhatn added a commit that referenced this pull request Feb 22, 2021
We can't enable the sequential access optimization for stored fields of 
changes snapshots used in peer recoveries because they are accessed by
multiple threads.

Relates to #68961
dnhatn added a commit to dnhatn/elasticsearch that referenced this pull request Feb 22, 2021
We can't enable the sequential access optimization for stored fields of
changes snapshots used in peer recoveries because they are accessed by
multiple threads.

Relates to elastic#68961
dnhatn added a commit that referenced this pull request Feb 23, 2021
We can't enable the sequential access optimization for stored fields of
changes snapshots used in peer recoveries because they are accessed by
multiple threads.

Relates to #68961
dnhatn added a commit that referenced this pull request Feb 23, 2021
We can't enable the sequential access optimization for stored fields of
changes snapshots used in peer recoveries because they are accessed by
multiple threads.

Relates to #68961
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Distributed Indexing/CCR Issues around the Cross Cluster State Replication features >enhancement Team:Distributed (Obsolete) Meta label for distributed team (obsolete). Replaced by Distributed Indexing/Coordination. v7.12.0 v8.0.0-alpha1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants