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 #8927

Merged
merged 17 commits into from
Apr 26, 2024

Conversation

Lloyd-Pottiger
Copy link
Contributor

@Lloyd-Pottiger Lloyd-Pottiger commented Apr 10, 2024

What problem does this PR solve?

Issue Number: close #8904

Problem Summary:

In the previous implementation, I used insertManyFrom to insert data in ConstColumn into the target column.

void insertManyFrom(const IColumn & src, size_t position, size_t length) override
{
const auto & value = static_cast<const Self &>(src).getData()[position];
data.resize_fill(data.size() + length, value);
}

In insertManyFrom, ColumnVector::insertManyFrom only expected calling src with exactly the same type of Self rather than any subclass of IColumn. If we do so, static_cast<const Self &>(src).getData() just returns a random memory location. It causes the del tag column contains too much non-zero value, leading to return less data than expected.

What is changed and how it works?

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

Lloyd-Pottiger and others added 5 commits April 10, 2024 10:52
Signed-off-by: Lloyd-Pottiger <yan1579196623@gmail.com>
Signed-off-by: Lloyd-Pottiger <yan1579196623@gmail.com>
Signed-off-by: Lloyd-Pottiger <yan1579196623@gmail.com>
Signed-off-by: Lloyd-Pottiger <yan1579196623@gmail.com>
@ti-chi-bot ti-chi-bot bot added 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. labels Apr 10, 2024
@CalvinNeo
Copy link
Member

Could you elaborate the bug in this issue

@Lloyd-Pottiger
Copy link
Contributor Author

Could you elaborate the bug in this issue

done

@JaySon-Huang
Copy link
Contributor

In insertManyFrom, the data is get from the container, but ConstColumn does not have any container.

Actually, ColumnVector::insertManyFrom only expected calling src with exactly the same type of Self rather than any subclass of IColumn. If we do so, static_cast<const Self &>(src).getData() just returns a random memory location.

@Lloyd-Pottiger
Copy link
Contributor Author

In insertManyFrom, the data is get from the container, but ConstColumn does not have any container.

Actually, ColumnVector::insertManyFrom only expected calling src with exactly the same type of Self rather than any subclass of IColumn. If we do so, static_cast<const Self &>(src).getData() just returns a random memory location.

updated

@JaySon-Huang
Copy link
Contributor

/hold
need to verify with coverage report

@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 11, 2024
@Lloyd-Pottiger
Copy link
Contributor Author

image image

@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 15, 2024
Signed-off-by: Lloyd-Pottiger <yan1579196623@gmail.com>
Co-authored-by: jinhelin <linjinhe33@gmail.com>
release-centos7-llvm/gen_coverage.sh Show resolved Hide resolved
Comment on lines 227 to +253
Block block = read();
size_t rows = block.rows();

IColumn::Filter block_filter(filter.cbegin() + read_rows, filter.cbegin() + read_rows + block.rows());
read_rows += block.rows();

if (size_t passed_count = countBytesInFilter(block_filter); passed_count != block.rows())
if (size_t passed_count = countBytesInFilter(filter, offset, rows); passed_count != rows)
{
for (auto & col : block)
std::vector<size_t> positions;
positions.reserve(passed_count);
for (size_t p = offset; p < offset + rows; ++p)
{
col.column = col.column->filter(block_filter, passed_count);
if (filter[p])
positions.push_back(p - offset);
}
for (size_t i = 0; i < block.columns(); ++i)
{
columns[i]->insertDisjunctFrom(*block.getByPosition(i).column, positions);
}
}

blocks.emplace_back(std::move(block));
else
{
for (size_t i = 0; i < block.columns(); ++i)
{
columns[i]->insertRangeFrom(
*block.getByPosition(i).column,
0,
block.getByPosition(i).column->size());
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

We assume readWithFilter will never be called on the three hidden columns, so we don't need to take care about whether the block.getByPosition(i).column is ColumnConst or not?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

image

clean read is not enabled when there are hidden columns.

Comment on lines +246 to +252
for (size_t i = 0; i < block.columns(); ++i)
{
columns[i]->insertRangeFrom(
*block.getByPosition(i).column,
0,
block.getByPosition(i).column->size());
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Are there any cases cover this branch?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is kind of hard to construct.... #8927 (comment) never do clean read here, so the source and target column are must be the same.

Signed-off-by: Lloyd-Pottiger <yan1579196623@gmail.com>
Lloyd-Pottiger and others added 2 commits April 16, 2024 10:39
Signed-off-by: Lloyd-Pottiger <yan1579196623@gmail.com>
@ti-chi-bot ti-chi-bot bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 18, 2024
@ti-chi-bot ti-chi-bot bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 19, 2024
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 bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Apr 22, 2024
@ti-chi-bot ti-chi-bot bot added the lgtm label Apr 26, 2024
Copy link
Contributor

ti-chi-bot bot commented Apr 26, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: JaySon-Huang, 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:
  • OWNERS [JaySon-Huang,JinheLin]

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

@ti-chi-bot ti-chi-bot bot removed the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Apr 26, 2024
Copy link
Contributor

ti-chi-bot bot commented Apr 26, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-04-22 03:04:37.48262518 +0000 UTC m=+825696.593671617: ☑️ agreed by JaySon-Huang.
  • 2024-04-26 09:46:16.912907791 +0000 UTC m=+4930.670043361: ☑️ agreed by JinheLin.

Copy link
Contributor

ti-chi-bot bot commented Apr 26, 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.

@ti-chi-bot ti-chi-bot bot merged commit 98e4a7c into pingcap:master Apr 26, 2024
6 checks passed
@Lloyd-Pottiger Lloyd-Pottiger deleted the refactor-dmfile-reader branch May 8, 2024 08:40
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.

TiFlash result is wrong
4 participants