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

PageStorage: Mvcc directory (without GC/restore) #3637

Merged
merged 17 commits into from
Dec 23, 2021

Conversation

JaySon-Huang
Copy link
Contributor

@JaySon-Huang JaySon-Huang commented Dec 13, 2021

What problem does this PR solve?

Issue Number: related to #3594

Problem Summary:

This PR focus on implementing the apply changes to / read PageEntry from MVCC directory.

These functions will be implemented in the following PRs:

  • Persisting to/restoring from WALStore
  • GC deleted pages

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

@ti-chi-bot
Copy link
Member

ti-chi-bot commented Dec 13, 2021

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • jiaqizho

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/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Dec 13, 2021
@JaySon-Huang JaySon-Huang changed the title PageStorage: Mvcc directory (without GC/restore) [WIP] PageStorage: Mvcc directory (without GC/restore) Dec 13, 2021
@ti-chi-bot ti-chi-bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Dec 13, 2021
@JaySon-Huang JaySon-Huang force-pushed the ps_mvcc_directory branch 2 times, most recently from 318da99 to e6bcc78 Compare December 13, 2021 11:24
@JaySon-Huang
Copy link
Contributor Author

/run-all-tests

JaySon-Huang and others added 5 commits December 15, 2021 13:46
Signed-off-by: JaySon-Huang <tshent@qq.com>
Signed-off-by: JaySon-Huang <tshent@qq.com>
Signed-off-by: JaySon-Huang <tshent@qq.com>
Signed-off-by: JaySon-Huang <tshent@qq.com>
Signed-off-by: JaySon-Huang <tshent@qq.com>
Signed-off-by: JaySon-Huang <tshent@qq.com>
…st entry

Signed-off-by: JaySon-Huang <tshent@qq.com>
Signed-off-by: JaySon-Huang <tshent@qq.com>
@JaySon-Huang
Copy link
Contributor Author

/run-all-tests

@JaySon-Huang
Copy link
Contributor Author

/run-all-tests

Signed-off-by: JaySon-Huang <tshent@qq.com>
Signed-off-by: JaySon-Huang <tshent@qq.com>
@JaySon-Huang JaySon-Huang changed the title [WIP] PageStorage: Mvcc directory (without GC/restore) PageStorage: Mvcc directory (without GC/restore) Dec 16, 2021
@ti-chi-bot ti-chi-bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Dec 16, 2021
@JaySon-Huang
Copy link
Contributor Author

@jiaqizho PTAL

@JaySon-Huang
Copy link
Contributor Author

/run-all-tests

Signed-off-by: JaySon-Huang <tshent@qq.com>
@sre-bot
Copy link
Collaborator

sre-bot commented Dec 16, 2021

Coverage detail: https://ci-internal.pingcap.net/job/tics_ghpr_unit_test/415/cobertura/
(Coverage detail url is limited office network access)

lines: 42.5% (47422 out of 111506)
branches: 6.0% (72913 out of 1207629)

}

// stage 2, persisted the changes to WAL
// wal.apply(edit);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why comment out this line?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because WALStore has not been implemented in this PR (but its tests don't care about this stage). So I comment out this line.

dbms/src/Storages/Page/V3/PageDirectory.cpp Show resolved Hide resolved
else
++iter;
}
throw Exception("Not implemented", ErrorCodes::NOT_IMPLEMENTED);
Copy link
Contributor

Choose a reason for hiding this comment

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

Then after clean up snapshots, it must throw an exception, can we make a test version of this method or just not do GC ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This PR doesn't focus on GC. So I won't test/fix this line in this PR.

{
assert(del == true);
}
explicit EntryOrDelete(const PageEntryV3 & entry_)
Copy link
Contributor

Choose a reason for hiding this comment

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

Just a suggestion, can we use nullptr and a entry ptr to replace it?

looks strange to me....

Copy link
Contributor Author

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 for using nullptr representing "delete". It will cause

  • many small heap allocation/freeing
  • need to dereference to get the actual entry, slowing down the query performance

Copy link
Contributor

Choose a reason for hiding this comment

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

So why we do not use real ptr to replace it?
ex.

std::map<PageVersionType, PageEntryV3 *> entries;

it does not mean entry will be in heap.

and I don't agree with many small heap allocation/freeing this point.

If lots of entries are in the stack, the single thread stack is 8M. Not sure will get an error from it.

Anyway, it is just a suggestion(change or not, all is fine), In my opinion, the expression of pointers and nullptr would be more appropriate here.

Copy link
Contributor

@jiaqizho jiaqizho left a comment

Choose a reason for hiding this comment

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

LGTM,

There still remain many things to do. :)

{
assert(del == true);
}
explicit EntryOrDelete(const PageEntryV3 & entry_)
Copy link
Contributor

Choose a reason for hiding this comment

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

So why we do not use real ptr to replace it?
ex.

std::map<PageVersionType, PageEntryV3 *> entries;

it does not mean entry will be in heap.

and I don't agree with many small heap allocation/freeing this point.

If lots of entries are in the stack, the single thread stack is 8M. Not sure will get an error from it.

Anyway, it is just a suggestion(change or not, all is fine), In my opinion, the expression of pointers and nullptr would be more appropriate here.

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Dec 21, 2021

void PageDirectory::apply(PageEntriesEdit && edit)
{
std::unique_lock write_lock(table_rw_mutex); // TODO: It is totally serialized, make it a pipeline
Copy link
Contributor

Choose a reason for hiding this comment

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

lock_guard?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

unique_lock/shared_lock is more suitable for write/read lock because table_rw_mutex is a shared_mutex.

@jiaqizho
Copy link
Contributor

/rebuild

@JaySon-Huang
Copy link
Contributor Author

/run-all-tests

@sre-bot
Copy link
Collaborator

sre-bot commented Dec 22, 2021

Coverage detail: https://ci-internal.pingcap.net/job/tics_ghpr_unit_test/548/cobertura/
(Coverage detail url is limited office network access)

lines: 42.7% (47925 out of 112314)
branches: 6.1% (73487 out of 1210490)

@JaySon-Huang
Copy link
Contributor Author

/merge

@ti-chi-bot
Copy link
Member

@JaySon-Huang: 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: 7e14e59

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Dec 23, 2021
@ti-chi-bot
Copy link
Member

@JaySon-Huang: 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 Dec 23, 2021

Coverage detail: https://ci-internal.pingcap.net/job/tics_ghpr_unit_test/569/cobertura/
(Coverage detail url is limited office network access)

lines: 42.7% (48015 out of 112357)
branches: 6.1% (73578 out of 1210512)

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/LGT1 Indicates that a PR has LGTM 1.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants