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

storage: Merge multiple segments in gc thread #5863

Merged
merged 27 commits into from
Sep 15, 2022
Merged

Conversation

breezewish
Copy link
Member

@breezewish breezewish commented Sep 13, 2022

What problem does this PR solve?

Issue Number: ref #5237

Problem Summary:

What is changed and how it works?

In this PR, segment merge will be only running in the GC thread, instead of in other background threads. This means segment merge will have much lower priority than other segment operations now.

This PR also try to merge multiple segments all at once. This reduces write amplification when there are a lot of small segments.

The merge strategy: Pick segments until reaching (segment_limit_rows|size)/3.

Note: In the current strategy, the following segment sequence will not get merged, thus leaving a small segment in the wild:
[size=0, size=1GB] as 0+1GB > 512MB/3.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)

Workload: Full-speed Ingest using IngestBySplit

The workload is to first ingest replicas in full-speed, then perform full table scan for multiple times.

image

image

image

(Note: we added a sleep to flush retry in the previous PR. It also contributes to the decrease of flush.)

image

Query performance (30 sec interval) right after replica sync is finished:

  • Merge in GC: 17.79 sec, 16.80 sec, 16.61 sec, 16.92 sec
  • Merge in BG: 29.03 sec, 23.97 sec, 26.07 sec, 17.89 sec

We can see that query is less likely to be affected due to small number of background tasks.

However, notice that at the time when these query finished, there are still more merge tasks to do. There was still 35% remaining merge tasks (according to the TIFLASH_SEGMENTS table):

image

Workload: Normal-speed Ingest using IngestBySplit

image

image

image

  • No code

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

None

@breezewish breezewish added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 13, 2022
@ti-chi-bot
Copy link
Member

ti-chi-bot commented Sep 13, 2022

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • JaySon-Huang
  • flowbehappy

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

The full list of commands accepted by this bot can be found here.

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot ti-chi-bot added release-note-none Denotes a PR that doesn't merit a release note. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Sep 13, 2022
@breezewish breezewish changed the title storage: Run segment merge in gc thread storage: Merge multiple segments in gc thread Sep 13, 2022
Signed-off-by: Wish <[email protected]>
@ti-chi-bot ti-chi-bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Sep 13, 2022
@breezewish breezewish removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 13, 2022
@breezewish breezewish requested review from JaySon-Huang and removed request for JaySon-Huang September 13, 2022 14:07
Copy link
Contributor

@JaySon-Huang JaySon-Huang left a comment

Choose a reason for hiding this comment

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

lgtm

@ti-chi-bot ti-chi-bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Sep 15, 2022
Signed-off-by: Wish <[email protected]>
@breezewish
Copy link
Member Author

/merge

@ti-chi-bot
Copy link
Member

@breezewish: It seems you want to merge this PR, I will help you trigger all the tests:

/run-all-tests

You only need to trigger /merge once, and if the CI test fails, you just re-trigger the test that failed and the bot will merge the PR for you after the CI passes.

If you have any questions about the PR merge process, please refer to pr process.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository.

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: e37ff2d

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Sep 15, 2022
@sre-bot
Copy link
Collaborator

sre-bot commented Sep 15, 2022

Coverage for changed files

Filename                                                     Regions    Missed Regions     Cover   Functions  Missed Functions  Executed       Lines      Missed Lines     Cover    Branches   Missed Branches     Cover
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Common/FailPoint.cpp                                             602               221    63.29%           8                 2    75.00%          84                36    57.14%         204               108    47.06%
Storages/DeltaMerge/DMContext.h                                    4                 0   100.00%           4                 0   100.00%           7                 0   100.00%           0                 0         -
Storages/DeltaMerge/DeltaMergeStore.cpp                          897               156    82.61%          46                 2    95.65%        1312               229    82.55%         470               155    67.02%
Storages/DeltaMerge/DeltaMergeStore.h                             41                13    68.29%          19                 3    84.21%         107                31    71.03%          42                10    76.19%
Storages/DeltaMerge/DeltaMergeStore_InternalBg.cpp               454               202    55.51%          16                 2    87.50%         573               182    68.24%         214               100    53.27%
Storages/DeltaMerge/DeltaMergeStore_InternalSegment.cpp          422               205    51.42%           4                 0   100.00%         336                78    76.79%         114                57    50.00%
Storages/DeltaMerge/tests/MultiSegmentTestUtil.h                  46                 2    95.65%           6                 0   100.00%          86                 0   100.00%          10                 2    80.00%
Storages/DeltaMerge/tests/gtest_dm_delta_merge_store.cpp         982               370    62.32%          77                 1    98.70%        2933                69    97.65%         284               203    28.52%
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL                                                           3448              1169    66.10%         180                10    94.44%        5438               625    88.51%        1338               635    52.54%

Coverage summary

Functions  MissedFunctions  Executed  Lines   MissedLines  Cover
18762      8126             56.69%    217342  83429        61.61%

full coverage report (for internal network access only)

@breezewish
Copy link
Member Author

/merge

@ti-chi-bot
Copy link
Member

@breezewish: It seems you want to merge this PR, I will help you trigger all the tests:

/run-all-tests

You only need to trigger /merge once, and if the CI test fails, you just re-trigger the test that failed and the bot will merge the PR for you after the CI passes.

If you have any questions about the PR merge process, please refer to pr process.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository.

@sre-bot
Copy link
Collaborator

sre-bot commented Sep 15, 2022

Coverage for changed files

Filename                                                     Regions    Missed Regions     Cover   Functions  Missed Functions  Executed       Lines      Missed Lines     Cover    Branches   Missed Branches     Cover
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Common/FailPoint.cpp                                             602               221    63.29%           8                 2    75.00%          84                36    57.14%         204               108    47.06%
Storages/DeltaMerge/DMContext.h                                    4                 0   100.00%           4                 0   100.00%           7                 0   100.00%           0                 0         -
Storages/DeltaMerge/DeltaMergeStore.cpp                          897               157    82.50%          46                 2    95.65%        1312               229    82.55%         470               157    66.60%
Storages/DeltaMerge/DeltaMergeStore.h                             41                13    68.29%          19                 3    84.21%         107                31    71.03%          42                10    76.19%
Storages/DeltaMerge/DeltaMergeStore_InternalBg.cpp               454               202    55.51%          16                 2    87.50%         573               182    68.24%         214               100    53.27%
Storages/DeltaMerge/DeltaMergeStore_InternalSegment.cpp          422               205    51.42%           4                 0   100.00%         336                78    76.79%         114                57    50.00%
Storages/DeltaMerge/tests/MultiSegmentTestUtil.h                  46                 2    95.65%           6                 0   100.00%          86                 0   100.00%          10                 2    80.00%
Storages/DeltaMerge/tests/gtest_dm_delta_merge_store.cpp         982               370    62.32%          77                 1    98.70%        2933                69    97.65%         284               203    28.52%
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL                                                           3448              1170    66.07%         180                10    94.44%        5438               625    88.51%        1338               637    52.39%

Coverage summary

Functions  MissedFunctions  Executed  Lines   MissedLines  Cover
18762      8125             56.69%    217343  83418        61.62%

full coverage report (for internal network access only)

@ti-chi-bot ti-chi-bot removed the status/can-merge Indicates a PR has been approved by a committer. label Sep 15, 2022
@breezewish
Copy link
Member Author

/merge

@ti-chi-bot
Copy link
Member

@breezewish: It seems you want to merge this PR, I will help you trigger all the tests:

/run-all-tests

You only need to trigger /merge once, and if the CI test fails, you just re-trigger the test that failed and the bot will merge the PR for you after the CI passes.

If you have any questions about the PR merge process, please refer to pr process.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository.

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: df80965

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Sep 15, 2022
@sre-bot
Copy link
Collaborator

sre-bot commented Sep 15, 2022

Coverage for changed files

Filename                                                     Regions    Missed Regions     Cover   Functions  Missed Functions  Executed       Lines      Missed Lines     Cover    Branches   Missed Branches     Cover
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Common/FailPoint.cpp                                             602               221    63.29%           8                 2    75.00%          84                36    57.14%         204               108    47.06%
Storages/DeltaMerge/DMContext.h                                    4                 0   100.00%           4                 0   100.00%           7                 0   100.00%           0                 0         -
Storages/DeltaMerge/DeltaMergeStore.cpp                          897               156    82.61%          46                 2    95.65%        1312               229    82.55%         470               152    67.66%
Storages/DeltaMerge/DeltaMergeStore.h                             17                 3    82.35%          16                 3    81.25%          50                11    78.00%           0                 0         -
Storages/DeltaMerge/DeltaMergeStore_InternalBg.cpp               454               202    55.51%          16                 2    87.50%         573               182    68.24%         214               100    53.27%
Storages/DeltaMerge/DeltaMergeStore_InternalSegment.cpp          422               205    51.42%           4                 0   100.00%         336                78    76.79%         114                57    50.00%
Storages/DeltaMerge/tests/MultiSegmentTestUtil.h                  46                 2    95.65%           6                 0   100.00%          86                 0   100.00%          10                 2    80.00%
Storages/DeltaMerge/tests/gtest_dm_delta_merge_store.cpp         982               370    62.32%          77                 1    98.70%        2933                69    97.65%         284               203    28.52%
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL                                                           3424              1159    66.15%         177                10    94.35%        5381               605    88.76%        1296               622    52.01%

Coverage summary

Functions  MissedFunctions  Executed  Lines   MissedLines  Cover
18760      8127             56.68%    217310  83394        61.62%

full coverage report (for internal network access only)

@ti-chi-bot
Copy link
Member

@breezewish: Your PR was out of date, I have automatically updated it for you.

At the same time I will also trigger all tests for you:

/run-all-tests

If the CI test fails, you just re-trigger the test that failed and the bot will merge the PR for you after the CI passes.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository.

@sre-bot
Copy link
Collaborator

sre-bot commented Sep 15, 2022

Coverage for changed files

Filename                                                     Regions    Missed Regions     Cover   Functions  Missed Functions  Executed       Lines      Missed Lines     Cover    Branches   Missed Branches     Cover
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Common/FailPoint.cpp                                             602               221    63.29%           8                 2    75.00%          84                36    57.14%         204               108    47.06%
Storages/DeltaMerge/DMContext.h                                    4                 0   100.00%           4                 0   100.00%           7                 0   100.00%           0                 0         -
Storages/DeltaMerge/DeltaMergeStore.cpp                          897               156    82.61%          46                 2    95.65%        1312               229    82.55%         470               152    67.66%
Storages/DeltaMerge/DeltaMergeStore.h                             17                 3    82.35%          16                 3    81.25%          50                11    78.00%           0                 0         -
Storages/DeltaMerge/DeltaMergeStore_InternalBg.cpp               454               202    55.51%          16                 2    87.50%         573               182    68.24%         214               100    53.27%
Storages/DeltaMerge/DeltaMergeStore_InternalSegment.cpp          422               205    51.42%           4                 0   100.00%         336                78    76.79%         114                57    50.00%
Storages/DeltaMerge/tests/MultiSegmentTestUtil.h                  46                 2    95.65%           6                 0   100.00%          86                 0   100.00%          10                 2    80.00%
Storages/DeltaMerge/tests/gtest_dm_delta_merge_store.cpp         982               370    62.32%          77                 1    98.70%        2933                69    97.65%         284               203    28.52%
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL                                                           3424              1159    66.15%         177                10    94.35%        5381               605    88.76%        1296               622    52.01%

Coverage summary

Functions  MissedFunctions  Executed  Lines   MissedLines  Cover
18758      8124             56.69%    217306  83308        61.66%

full coverage report (for internal network access only)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note-none Denotes a PR that doesn't merit a release note. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants