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: (Refactor) Avoid referencing DeltaMergeStore.h #5835

Merged
merged 9 commits into from
Sep 13, 2022

Conversation

breezewish
Copy link
Member

@breezewish breezewish commented Sep 9, 2022

What problem does this PR solve?

Issue Number: ref #5831

  1. Currently the DeltaMerge/DeltaMergeStore.h is imported in Storages/StorageDeltaMerge.h, which makes the pimpl useless -- When changing private member functions in DeltaMerge/DeltaMergeStore.h, a lot of external functions need to be recompiled.
  2. It does not make sense to leak the "ThreadType" in the Delta Merge Public API, as background threads are purely internal.

What is changed and how it works?

  1. Changed TaskRunThread to MergeDeltaReason, which makes more sense.
  2. No need to specify TaskRunThread or MergeDeltaReason in DeltaMerge public API mergeDeltaBySegment, as run thread or merge reason are purely internal.
  3. Forward declare RowKeyValue so that the import of internal DeltaMerge headers can be avoided.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • 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

@ti-chi-bot
Copy link
Member

ti-chi-bot commented Sep 9, 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. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Sep 9, 2022
@ti-chi-bot ti-chi-bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Sep 9, 2022
@@ -14,29 +14,24 @@

#pragma once

#include <Common/Logger.h>
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we remove this header file?

Copy link
Member Author

@breezewish breezewish Sep 13, 2022

Choose a reason for hiding this comment

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

It should be a better practice to include everything you used in this header file as possible, even if it may be included transitively by other included header files. In this way, this header is less likely to break when other headers are refactored.

In this case, as StorageDeltaMerge has a field of type LoggerPtr, we could explicitly introduce it.

Copy link
Contributor

Choose a reason for hiding this comment

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

We can use forward declaration here, using

namespace DB
{
class Logger;
using LoggerPtr = std::shared_ptr<Logger>;
}

instead of including the <Common/Logger.h>.

Here I think both are OK since Common/Logger.h itself is a clean header file that doesn't bring many other header files.

@breezewish
Copy link
Member Author

/run-all-tests

@sre-bot
Copy link
Collaborator

sre-bot commented Sep 13, 2022

Coverage for changed files

Filename                                                     Regions    Missed Regions     Cover   Functions  Missed Functions  Executed       Lines      Missed Lines     Cover    Branches   Missed Branches     Cover
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Common/TiFlashMetrics.h                                           18                 0   100.00%          11                 0   100.00%          47                 1    97.87%           8                 0   100.00%
Flash/Management/ManualCompact.cpp                               138                54    60.87%           9                 0   100.00%         166                23    86.14%          50                20    60.00%
Storages/DeltaMerge/DeltaMergeStore.cpp                         1207               394    67.36%          58                 5    91.38%        1756               443    74.77%         618               247    60.03%
Storages/DeltaMerge/DeltaMergeStore.h                             42                12    71.43%          19                 3    84.21%         109                29    73.39%          44                 9    79.55%
Storages/DeltaMerge/DeltaMergeStore_Ingest.cpp                    97                18    81.44%           8                 0   100.00%         193                13    93.26%          40                11    72.50%
Storages/DeltaMerge/DeltaMergeStore_InternalSegment.cpp          413               213    48.43%           4                 0   100.00%         325                92    71.69%         110                67    39.09%
Storages/DeltaMerge/tests/gtest_dm_delta_merge_store.cpp         908               335    63.11%          68                 1    98.53%        2823                69    97.56%         264               183    30.68%
Storages/StorageDeltaMerge.cpp                                   717               276    61.51%          59                21    64.41%        1297               553    57.36%         364               198    45.60%
Storages/StorageDeltaMerge.h                                      11                 6    45.45%          11                 6    45.45%          17                 8    52.94%           0                 0         -
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL                                                           3551              1308    63.17%         247                36    85.43%        6733              1231    81.72%        1498               735    50.93%

Coverage summary

Functions  MissedFunctions  Executed  Lines   MissedLines  Cover
18709      8128             56.56%    216360  83546        61.39%

full coverage report (for internal network access only)

F(type_delta_merge_bg_gc, {"type", "delta_merge_bg_gc"}), \
F(type_delta_merge_fg, {"type", "delta_merge_fg"}), \
F(type_delta_merge_manual, {"type", "delta_merge_manual"}), \
Copy link
Contributor

Choose a reason for hiding this comment

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

Does grafana need to adjust?

Copy link
Member Author

Choose a reason for hiding this comment

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

In Grafana expressions are using "delta_merge|seg" as matchers, so there is no need to adjust.

Copy link
Contributor

@flowbehappy flowbehappy left a comment

Choose a reason for hiding this comment

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

LGTM with a minor comment

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Sep 13, 2022
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 13, 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: d85449e

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

sre-bot commented Sep 13, 2022

Coverage for changed files

Filename                                                     Regions    Missed Regions     Cover   Functions  Missed Functions  Executed       Lines      Missed Lines     Cover    Branches   Missed Branches     Cover
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Common/TiFlashMetrics.h                                           18                 0   100.00%          11                 0   100.00%          47                 1    97.87%           8                 0   100.00%
Flash/Management/ManualCompact.cpp                               138                54    60.87%           9                 0   100.00%         166                23    86.14%          50                20    60.00%
Storages/DeltaMerge/DeltaMergeStore.cpp                         1207               394    67.36%          58                 5    91.38%        1756               443    74.77%         618               246    60.19%
Storages/DeltaMerge/DeltaMergeStore.h                             42                12    71.43%          19                 3    84.21%         109                29    73.39%          44                 9    79.55%
Storages/DeltaMerge/DeltaMergeStore_Ingest.cpp                    97                18    81.44%           8                 0   100.00%         193                13    93.26%          40                11    72.50%
Storages/DeltaMerge/DeltaMergeStore_InternalSegment.cpp          413               213    48.43%           4                 0   100.00%         325                92    71.69%         110                67    39.09%
Storages/DeltaMerge/tests/gtest_dm_delta_merge_store.cpp         908               335    63.11%          68                 1    98.53%        2823                69    97.56%         264               183    30.68%
Storages/StorageDeltaMerge.cpp                                   717               276    61.51%          59                21    64.41%        1297               553    57.36%         364               198    45.60%
Storages/StorageDeltaMerge.h                                      11                 6    45.45%          11                 6    45.45%          17                 8    52.94%           0                 0         -
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL                                                           3551              1308    63.17%         247                36    85.43%        6733              1231    81.72%        1498               734    51.00%

Coverage summary

Functions  MissedFunctions  Executed  Lines   MissedLines  Cover
18709      8127             56.56%    216362  83494        61.41%

full coverage report (for internal network access only)

@ti-chi-bot ti-chi-bot merged commit 6d0cbc8 into master Sep 13, 2022
@JaySon-Huang JaySon-Huang deleted the wenxuan/dm_pimpl branch September 13, 2022 05:12
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/L Denotes a PR that changes 100-499 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