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

KVStore: Refine parallel prehandle snapshot (part-1) #9192

Merged
merged 2 commits into from
Jul 5, 2024

Conversation

JaySon-Huang
Copy link
Contributor

@JaySon-Huang JaySon-Huang commented Jul 5, 2024

What problem does this PR solve?

Issue Number: ref #8081

Problem Summary:

I'd like to introduce a new layer SnapshotSSTReader and move getApproxBytes/findSplitKeys into that layer. This could make the logic in parallel prehandle snapshots more clear.

This PR is a preceding PR that refactors the code to simplify the following logical change.

New SnapshotSSTReader interface in later PR:

struct SnapshotSSTReader
{
    SnapshotSSTReader(
        const SSTViewVec & snaps,
        const TiFlashRaftProxyHelper * proxy_helper,
        RegionID region_id,
        UInt64 snapshot_index,
        const ImutRegionRangePtr & region_range,
        std::optional<SSTScanSoftLimit> && soft_limit,
        const String & log_prefix);

    // Currently it only takes effect if using tablet sst reader which is usually a raftstore v2 case.
    // Otherwise will return zero.
    size_t getApproxBytes() const;
    std::vector<std::string> findSplitKeys(size_t splits_count) const;

    using SSTReaderPtr = std::unique_ptr<SSTReader>;
    SSTReaderPtr write_cf_reader;
    SSTReaderPtr default_cf_reader;
    SSTReaderPtr lock_cf_reader;
};

What is changed and how it works?


  • Unify extra_id by split_id
  • Unify the return type of executeParallelTransform and executeTransform to be std::tuple<ReadFromStreamResult, PrehandleResult>
  • Apply "early return" on executeParallelTransform to simplify the code indent layer

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

@JaySon-Huang JaySon-Huang requested a review from CalvinNeo July 5, 2024 05:26
@ti-chi-bot ti-chi-bot bot added do-not-merge/needs-linked-issue 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 Jul 5, 2024
Copy link
Contributor

@Lloyd-Pottiger Lloyd-Pottiger left a comment

Choose a reason for hiding this comment

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

Others LGTM

dbms/src/Storages/KVStore/MultiRaft/PrehandleSnapshot.cpp Outdated Show resolved Hide resolved
dbms/src/Storages/KVStore/MultiRaft/PrehandleSnapshot.cpp Outdated Show resolved Hide resolved
dbms/src/Storages/KVStore/MultiRaft/PrehandleSnapshot.cpp Outdated Show resolved Hide resolved
@ti-chi-bot ti-chi-bot bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Jul 5, 2024
Copy link
Member

@CalvinNeo CalvinNeo left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link
Contributor

ti-chi-bot bot commented Jul 5, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: CalvinNeo, Lloyd-Pottiger

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 [CalvinNeo,Lloyd-Pottiger]

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 added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Jul 5, 2024
Copy link
Contributor

ti-chi-bot bot commented Jul 5, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-07-05 09:33:36.141627779 +0000 UTC m=+4513.376861891: ☑️ agreed by Lloyd-Pottiger.
  • 2024-07-05 11:27:00.459107998 +0000 UTC m=+11317.694342108: ☑️ agreed by CalvinNeo.

@ti-chi-bot ti-chi-bot bot merged commit cc1bf74 into pingcap:master Jul 5, 2024
5 checks passed
@JaySon-Huang JaySon-Huang deleted the refine_para_prehandle branch July 5, 2024 11:35
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/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants