Skip to content

Adaptive mark_segment_size for parallel replicas#68424

Merged
nickitat merged 20 commits intomasterfrom
adaptive_parallel_replicas
Sep 17, 2024
Merged

Adaptive mark_segment_size for parallel replicas#68424
nickitat merged 20 commits intomasterfrom
adaptive_parallel_replicas

Conversation

@nickitat
Copy link
Member

@nickitat nickitat commented Aug 15, 2024

Changelog category (leave one):

  • Performance Improvement

Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):

New algorithm to determine the unit of marks distribution between replicas by consistent hash. Different numbers of marks chosen for different read patterns to improve performance.


The essence of the changes:

  • new algorithm to choose unit of marks distribution by consistent hash (description)
  • changes in PR-s protocol, separate versioning is now actually versioning

CI Settings (Only check the boxes if you know what you are doing):

  • Allow: All Required Checks
  • Allow: Stateless tests
  • Allow: Stateful tests
  • Allow: Integration Tests
  • Allow: Performance tests
  • Allow: All Builds
  • Allow: batch 1, 2 for multi-batch jobs
  • Allow: batch 3, 4, 5, 6 for multi-batch jobs

  • Exclude: Style check
  • Exclude: Fast test
  • Exclude: All with ASAN
  • Exclude: All with TSAN, MSAN, UBSAN, Coverage
  • Exclude: All with aarch64, release, debug

  • Run only fuzzers related jobs (libFuzzer fuzzers, AST fuzzers, etc.)
  • Exclude: AST fuzzers

  • Do not test
  • Woolen Wolfdog
  • Upload binaries for special builds
  • Disable merge-commit
  • Disable CI cache

@robot-ch-test-poll1 robot-ch-test-poll1 added the pr-performance Pull request with some performance improvements label Aug 15, 2024
@robot-ch-test-poll4
Copy link
Contributor

robot-ch-test-poll4 commented Aug 15, 2024

This is an automated comment for commit 6357750 with description of existing statuses. It's updated for the latest CI running

❌ Click here to open a full report in a separate page

Check nameDescriptionStatus
AST fuzzerRuns randomly generated queries to catch program errors. The build type is optionally given in parenthesis. If it fails, ask a maintainer for help❌ failure
Stateless testsRuns stateless functional tests for ClickHouse binaries built in various configurations -- release, debug, with sanitizers, etc❌ failure
Successful checks
Check nameDescriptionStatus
BuildsThere's no description for the check yet, please add it to tests/ci/ci_config.py:CHECK_DESCRIPTIONS✅ success
ClickBenchRuns [ClickBench](https://github.com/ClickHouse/ClickBench/) with instant-attach table✅ success
Compatibility checkChecks that clickhouse binary runs on distributions with old libc versions. If it fails, ask a maintainer for help✅ success
Docker keeper imageThe check to build and optionally push the mentioned image to docker hub✅ success
Docker server imageThe check to build and optionally push the mentioned image to docker hub✅ success
Docs checkBuilds and tests the documentation✅ success
Fast testNormally this is the first check that is ran for a PR. It builds ClickHouse and runs most of stateless functional tests, omitting some. If it fails, further checks are not started until it is fixed. Look at the report to see which tests fail, then reproduce the failure locally as described here✅ success
Flaky testsChecks if new added or modified tests are flaky by running them repeatedly, in parallel, with more randomization. Functional tests are run 100 times with address sanitizer, and additional randomization of thread scheduling. Integration tests are run up to 10 times. If at least once a new test has failed, or was too long, this check will be red. We don't allow flaky tests, read the doc✅ success
Install packagesChecks that the built packages are installable in a clear environment✅ success
Integration testsThe integration tests report. In parenthesis the package type is given, and in square brackets are the optional part/total tests✅ success
Performance ComparisonMeasure changes in query performance. The performance test report is described in detail here. In square brackets are the optional part/total tests✅ success
Stateful testsRuns stateful functional tests for ClickHouse binaries built in various configurations -- release, debug, with sanitizers, etc✅ success
Stress testRuns stateless functional tests concurrently from several clients to detect concurrency-related errors✅ success
Style checkRuns a set of checks to keep the code style clean. If some of tests failed, see the related log from the report✅ success
Unit testsRuns the unit tests for different release types✅ success
Upgrade checkRuns stress tests on server version from last release and then tries to upgrade it to the version from the PR. It checks if the new server can successfully startup without any errors, crashes or sanitizer asserts✅ success

@devcrafter devcrafter self-assigned this Aug 15, 2024
@nickitat nickitat marked this pull request as ready for review August 18, 2024 22:41
@nikitamikhaylov nikitamikhaylov self-assigned this Aug 21, 2024
Copy link
Member

@devcrafter devcrafter left a comment

Choose a reason for hiding this comment

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

LGTM with comments

/// Here we take max of two numbers:
/// * (min_marks_per_task * threads) = the number of marks we request from the coordinator each time - there is no point to have segments smaller than one unit of work for a replica
/// * (sum_marks / number_of_replicas^2) - we use consistent hashing for work distribution (including work stealing). If we have a really slow replica
/// everything up to (1/number_of_replicas) portion of its work will be stolen by other replicas. And it owns (1/number_of_replicas) share of total number of marks.
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't it be like this?

Suggested change
/// everything up to (1/number_of_replicas) portion of its work will be stolen by other replicas. And it owns (1/number_of_replicas) share of total number of marks.
/// everything up to ((number_of_replicas-1)/number_of_replicas) portion of its work will be stolen by other replicas. And it owns (1/number_of_replicas) share of total number of marks.

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah, i should prob say 'except' instead of 'up to'

@nickitat
Copy link
Member Author

Integration tests (aarch64) [5/6] - #69449

@nickitat
Copy link
Member Author

waiting for #69602 to merge with master

@nickitat
Copy link
Member Author

AST fuzzer (debug) - #68296
Stateless tests (tsan) [1/4] - not sure if it the reason for t/o but there is sanitizer report in logs #49156

@devcrafter devcrafter self-requested a review September 16, 2024 19:27

static constexpr auto DBMS_PARALLEL_REPLICAS_PROTOCOL_VERSION = 3;
static constexpr auto DBMS_MIN_SUPPORTED_PARALLEL_REPLICAS_PROTOCOL_VERSION = 3;
static constexpr auto DBMS_PARALLEL_REPLICAS_PROTOCOL_VERSION = 4;
Copy link
Member

Choose a reason for hiding this comment

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

It looks like the previous approach - using only CH client protocol version, was the right one. Every time, we need to change the PR protocol, it's necessary to change the client protocol version anyway.
It's because of the case when first request is sent by a version with a bigger protocol number than the recipient.

Let's consider 2 replicas communication with PR protocol v2 and v1 (v2 > v1, v1 >= DBMS_MIN_SUPPORTED_PARALLEL_REPLICAS_PROTOCOL_VERSION).
In this case, v2 replica needs to communicate with v1 replicas by v1 protocol. But v2 replicas can understand it only from client protocol version of v1 replica. This means that every time we change PR protocol, we have to increase CH client protocol version to cover this case. Which, in turn, makes PR protocol version unnecessary

By using purely PR protocol, we'd have to introduce a handshake phase, during which peers agree which protocol version to use - which is an additional RTT, i.e. waste of time/network.

Copy link
Member

Choose a reason for hiding this comment

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

Sorry, miss that the parallel replicas protocol version within this PR is part of client protocol now. So, we're getting it during client protocol handshake, - so, the PR protocol version of remote peer is known at first PR request to the peer.

@nickitat nickitat enabled auto-merge September 17, 2024 12:22
@nickitat nickitat added this pull request to the merge queue Sep 17, 2024
Merged via the queue into master with commit ffaf97a Sep 17, 2024
@nickitat nickitat deleted the adaptive_parallel_replicas branch September 17, 2024 14:35
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Sep 17, 2024
github-merge-queue bot pushed a commit that referenced this pull request Sep 19, 2024
Fix parallel replicas protocol after #68424
zvonand pushed a commit to Altinity/ClickHouse that referenced this pull request Dec 2, 2024
…_replicas

Adaptive mark_segment_size for parallel replicas
zvonand pushed a commit to Altinity/ClickHouse that referenced this pull request Dec 3, 2024
…_replicas

Adaptive mark_segment_size for parallel replicas
zvonand pushed a commit to Altinity/ClickHouse that referenced this pull request Dec 13, 2024
…_replicas

Adaptive mark_segment_size for parallel replicas
zvonand pushed a commit to Altinity/ClickHouse that referenced this pull request Dec 17, 2024
…_replicas

Adaptive mark_segment_size for parallel replicas
zvonand pushed a commit to Altinity/ClickHouse that referenced this pull request Dec 17, 2024
Enmk pushed a commit to Altinity/ClickHouse that referenced this pull request Dec 22, 2024
…_replicas

Adaptive mark_segment_size for parallel replicas
Enmk pushed a commit to Altinity/ClickHouse that referenced this pull request Dec 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-performance Pull request with some performance improvements pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants