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

Support using FineGrainedShuffle Info for Join&Agg #6279

Merged
merged 25 commits into from
Nov 15, 2022

Conversation

yibin87
Copy link
Contributor

@yibin87 yibin87 commented Nov 9, 2022

Signed-off-by: yibin [email protected]

What problem does this PR solve?

Issue Number: ref #6157

Problem Summary:

What is changed and how it works?

FineGrainedShuffle info will be added in tidb side if the plan satisfies certain rules. In TiFlash side, both Join and Agg operators can benefit from these info:

  • Aggregation can parallelly process all streams without merging phase.
  • Join can build hash tables without any synchronizations, since rows with same key will be scattered to the same stream(It is guranteed by FineGrainedShuffleWriter).

A little refact of HashBaseWriteHelper to make parameters sequence more reasonable and other little changes.

Most changed logic is protected by enable_fine_grained_shuffle flag which is set false now in TiDB. Will add another separate PR to add gtests for FinedGrainedShuffleJoin&Agg then.

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 Nov 9, 2022

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • SeaRise
  • windtalker

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 do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. 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/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Nov 9, 2022
@ti-chi-bot ti-chi-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 9, 2022
@ti-chi-bot ti-chi-bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Nov 10, 2022
@yibin87 yibin87 changed the title [WIP] Support using FineGrainedShuffle Info for Join&Agg Support using FineGrainedShuffle Info for Join&Agg Nov 10, 2022
@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 Nov 10, 2022
Signed-off-by: yibin <[email protected]>
Signed-off-by: yibin <[email protected]>
@yibin87
Copy link
Contributor Author

yibin87 commented Nov 10, 2022

/run-unit-tests

@yibin87
Copy link
Contributor Author

yibin87 commented Nov 10, 2022

/run-integration-test

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

yibin87 commented Nov 10, 2022

/run-all-tests

dbms/src/Interpreters/Join.cpp Outdated Show resolved Hide resolved
dbms/src/Flash/Planner/plans/PhysicalJoin.cpp Outdated Show resolved Hide resolved
dbms/src/Flash/Planner/plans/PhysicalJoin.cpp Outdated Show resolved Hide resolved
@ti-chi-bot ti-chi-bot removed the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Nov 11, 2022
@@ -429,7 +429,8 @@ ExchangeReceiverBase<RPCContext>::ExchangeReceiverBase(
{
if (enableFineGrainedShuffle(fine_grained_shuffle_stream_count_))
{
for (size_t i = 0; i < max_streams_; ++i)
size_t channel_count = std::min(max_streams_, fine_grained_shuffle_stream_count_);
Copy link
Contributor

Choose a reason for hiding this comment

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

max_streams_ in ExchangeReceiver is actually useless, I think we can replace max_streams and fine_grained_shuffle_stream_count by output_stream_count and enable_fine_grained_shuffle?

Copy link
Contributor Author

@yibin87 yibin87 Nov 15, 2022

Choose a reason for hiding this comment

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

Make sense, updated

{
auto receiver_source_num_info = getReceiverSourceNumInfo(*build_pipeline.firstStream());
RUNTIME_CHECK(receiver_source_num_info.first == 1);
shuffle_partition_num = receiver_source_num_info.second;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why shuffle_partition_num is set to source_num?

Copy link
Contributor Author

@yibin87 yibin87 Nov 15, 2022

Choose a reason for hiding this comment

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

It was a wrong design, fixed it.

…e reproducing by hash and fine_grained_shuffle_stream_count

Signed-off-by: yibin <[email protected]>
Signed-off-by: yibin <[email protected]>
@SeaRise SeaRise self-requested a review November 14, 2022 07:24
@@ -41,44 +41,94 @@ std::vector<MutableColumns> createDestColumns(const Block & sample_block, size_t
return dest_tbl_cols;
}

void fillSelector(size_t rows,
const WeakHash32 & hash,
uint32_t num_bucket,
Copy link
Contributor

Choose a reason for hiding this comment

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

better to rename num_bucket to num_part?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

if (enable_fine_grained_shuffle && rows > 0)
{
/// TODO: consider adding a virtual column in Sender side to avoid computing cost and potential inconsistency by heterogeneous envs
/// Note: 1. Not sure, if inconsistency will do happen in heterogeneous envs
Copy link
Contributor

Choose a reason for hiding this comment

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

Why there maybe problems in heterogeneous envs?

Copy link
Contributor Author

@yibin87 yibin87 Nov 15, 2022

Choose a reason for hiding this comment

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

Added comments to make it clear.

@yibin87 yibin87 requested a review from windtalker November 15, 2022 01:14
@yibin87
Copy link
Contributor Author

yibin87 commented Nov 15, 2022

/run-all-tests

@yibin87 yibin87 requested a review from SeaRise November 15, 2022 05:38
Copy link
Contributor

@SeaRise SeaRise left a comment

Choose a reason for hiding this comment

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

Almost LGTM

dbms/src/Interpreters/Join.cpp Outdated Show resolved Hide resolved
@yibin87 yibin87 requested a review from SeaRise November 15, 2022 07:46
Copy link
Contributor

@SeaRise SeaRise 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 the status/LGT1 Indicates that a PR has LGTM 1. label Nov 15, 2022
Copy link
Contributor

@windtalker windtalker 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 Nov 15, 2022
@yibin87
Copy link
Contributor Author

yibin87 commented Nov 15, 2022

/merge

@ti-chi-bot
Copy link
Member

@yibin87: 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: 3c29db0

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Nov 15, 2022
@ti-chi-bot ti-chi-bot merged commit e77d01c into pingcap:master Nov 15, 2022
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/XL Denotes a PR that changes 500-999 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.

4 participants