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 DMFileReader #8854

Merged
merged 28 commits into from
Apr 3, 2024

Conversation

Lloyd-Pottiger
Copy link
Contributor

@Lloyd-Pottiger Lloyd-Pottiger commented Mar 20, 2024

What problem does this PR solve?

Issue Number: ref #6233

Problem Summary:

What is changed and how it works?

Refactor DMFileReader to make life easier~

Separate the packs can do clean read.

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 ti-chi-bot bot added 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. labels Mar 20, 2024
@ti-chi-bot ti-chi-bot bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Mar 20, 2024
@Lloyd-Pottiger
Copy link
Contributor Author

/run-all-tests

@Lloyd-Pottiger
Copy link
Contributor Author

/run-integration-test

{
PackRange target_range{start_pack_id, start_pack_id + pack_count};

RangeWithStrategys range_and_strategys;
Copy link
Member

Choose a reason for hiding this comment

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

Strategies

Copy link
Contributor Author

Choose a reason for hiding this comment

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

keep this, it means multiple RangeWithStrategy

Copy link
Member

Choose a reason for hiding this comment

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

I don't think it is a good idea, Poco is an example.
image

However, I think it isn't a big matter, don't take this as a serious review. Just my point of view.

Signed-off-by: Lloyd-Pottiger <[email protected]>
Signed-off-by: Lloyd-Pottiger <[email protected]>
Signed-off-by: Lloyd-Pottiger <[email protected]>
Signed-off-by: Lloyd-Pottiger <[email protected]>
@@ -142,7 +154,7 @@ class DMFileReader
/// Filters
DMFilePackFilter pack_filter;

std::vector<size_t> skip_packs_by_column{};
std::vector<bool> must_seek;
Copy link
Contributor

Choose a reason for hiding this comment

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

avoid using std::vector<bool>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

DMFileReader will be created for each segment in a query. If multiple queries are running at the same time, a lot of DMFileReader will be created. And if there are cop tasks, it is even worse. So reducing memory is important for DMFileReader.

And since must_seek is a private member, which means it only can be accessed inside, so no outer reference refers to it, meanwhile, the life cycle of the inside reference will always shorter than must_seek itself. So it is safe.

Copy link
Member

Choose a reason for hiding this comment

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

Why not use bitset?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

std::bitset can not decide size in run time. std::vecotr<bool> is safe in this case.

Copy link
Member

Choose a reason for hiding this comment

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

How about boost::dynamic_bitset? It is dynamic. Moreover, it supports efficient batch set bits (while std::fill(std::vector<bool>) does not stipulate its complexity and may have poor performance in some stds)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

boost::dynamic_bitset::operator[] also return a reference.

Anyway, must_seek is removed.

@Lloyd-Pottiger
Copy link
Contributor Author

/run-build-release

@sre-bot
Copy link
Collaborator

sre-bot commented Mar 29, 2024

Signed-off-by: Lloyd-Pottiger <[email protected]>
@Lloyd-Pottiger
Copy link
Contributor Author

Maintaining must_seek makes the code seem cumbersome and odd.

According to the code, the cost of seek is negligible if we don't really need to seek. Maybe we can remove must_seek and just seek every time before reading from disk.

https://github.com/pingcap/tiflash/blob/master/dbms/src/IO/Compression/CompressedReadBufferFromFile.cpp#L54-L83

Totally agree, I will remove it.

Signed-off-by: Lloyd-Pottiger <[email protected]>
Signed-off-by: Lloyd-Pottiger <[email protected]>
@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Apr 2, 2024
Copy link
Contributor

ti-chi-bot bot commented Apr 2, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: CalvinNeo, JinheLin

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

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Copy link
Contributor

ti-chi-bot bot commented Apr 2, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-03-29 05:19:24.500723741 +0000 UTC m=+2217991.522970124: ☑️ agreed by CalvinNeo.
  • 2024-04-02 09:14:02.327854737 +0000 UTC m=+348903.855395281: ☑️ agreed by JinheLin.

Copy link
Contributor

ti-chi-bot bot commented Apr 2, 2024

@Lloyd-Pottiger: 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

trigger some heavy tests which will not run always when PR updated.

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.

@Lloyd-Pottiger
Copy link
Contributor Author

/hold

@ti-chi-bot ti-chi-bot bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 2, 2024
Signed-off-by: Lloyd-Pottiger <[email protected]>
@Lloyd-Pottiger
Copy link
Contributor Author

/run-all-tests

@Lloyd-Pottiger
Copy link
Contributor Author

/run-unit-test

@Lloyd-Pottiger
Copy link
Contributor Author

/unhold

@ti-chi-bot ti-chi-bot bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 3, 2024
@Lloyd-Pottiger
Copy link
Contributor Author

/run-all-tests

@Lloyd-Pottiger
Copy link
Contributor Author

/run-unit-test

@ti-chi-bot ti-chi-bot bot merged commit 238e43c into pingcap:master Apr 3, 2024
6 checks passed
@Lloyd-Pottiger Lloyd-Pottiger deleted the refactor-dmfile branch April 8, 2024 02:54
JaySon-Huang added a commit that referenced this pull request Apr 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm 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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants