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

raft-engine: reduce the threshold of compression and add related metrics on it. #16906

Merged
merged 22 commits into from
May 9, 2024

Conversation

LykxSassinator
Copy link
Contributor

@LykxSassinator LykxSassinator commented Apr 23, 2024

What is changed and how it works?

Issue Number: Ref #16907 ref tikv/raft-engine#358

What's Changed:

This pr contains:
- Reduce the default compression threshold in RaftEngine to `4kb` as default if users do not manually set it.
- Add relevant metrics on the compression ratio of RaftEngine.write.

The relevant metrics will be shown just like the following shows:
image

And as for performance, taking tpcc workloads, using v7.5.x (disable async-io and compression-threshold = 8kb as default) as the baseline, the CPU.utilization keeps nearly same in this pr.
image
And using smaller compression threshold with batch-compression-threshold = 4kb, async-io, keeps the same, and the costs of IO Bandwidth are smaller than v8.1.0-nightly ((batch-compression-threshold = 8kb, async-io). (PS: smaller is better in "Disk IO Throughputs")

QPS Diff Disk IO Throughputs
image image

Related changes

  • PR to update pingcap/docs/pingcap/docs-cn:
  • Need to cherry-pick to the release branch

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

Release note

For the version of TIKV >= v8.1:
- Reduce the default compression threshold in RaftEngine to `4kb` as default if users do not manually set it.
- Add relevant metrics on the compression ratio of RaftEngine.write.

Signed-off-by: lucasliang <nkcs_lykx@hotmail.com>
Signed-off-by: lucasliang <nkcs_lykx@hotmail.com>
Signed-off-by: lucasliang <nkcs_lykx@hotmail.com>
Copy link
Contributor

ti-chi-bot bot commented Apr 23, 2024

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • SpadeA-Tang
  • glorv

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.

Copy link
Contributor

ti-chi-bot bot commented Apr 23, 2024

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@LykxSassinator
Copy link
Contributor Author

/test all

Signed-off-by: lucasliang <nkcs_lykx@hotmail.com>
@LykxSassinator
Copy link
Contributor Author

/retest-required

Signed-off-by: lucasliang <nkcs_lykx@hotmail.com>
@LykxSassinator LykxSassinator marked this pull request as ready for review April 25, 2024 03:28
Copy link
Contributor

@glorv glorv left a comment

Choose a reason for hiding this comment

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

rest LGTM

src/config/mod.rs Outdated Show resolved Hide resolved
Signed-off-by: lucasliang <nkcs_lykx@hotmail.com>
// better performance and reduce the IO overhead.
// Meanwhile, the batch_compression_threshold cannot be modified dynamically if
// the threads count of async-io are changed manually.
self.mut_config().batch_compression_threshold = RaftEngineReadableSize(std::cmp::max(
Copy link
Contributor

Choose a reason for hiding this comment

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

So does this means explicitly set config will also be changed? E.g, if user set the batch-compression-threshold to 16kb, it will be optimized to 8kb, is this expected behavior?
I still think we better make the logic straight and only do adjust if it is the default config.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep.

IMO, it's expected. As more async-io threads are set, smaller the batch of raft logs will be, the batch-compression-threshold should be adaptive to the size of async-io threads.

Copy link
Member

Choose a reason for hiding this comment

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

We should add a log if the config value is changed after optimization as it may surprise users.

Copy link
Member

Choose a reason for hiding this comment

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

Why not only set it when it isn't specified explicitly in config. 4kb may not be better for all cases.

Copy link
Contributor Author

@LykxSassinator LykxSassinator May 6, 2024

Choose a reason for hiding this comment

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

Then, how about introducing a flag raft_engine.customed, which will be true if the user manually set raft-engine.batch-compression-ratio with a specific value ?

And it can be combined with the current implementation that the batch-compression-threshold will be adaptive to the size of async-ios if the user does not set it on purpose.

As for 4kb, it's used to keep coincident with the minimal page size by default.

Copy link
Contributor

ti-chi-bot bot commented May 7, 2024

PR needs rebase.

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 kubernetes/test-infra repository.

src/config/mod.rs Outdated Show resolved Hide resolved
// better performance and reduce the IO overhead.
// Meanwhile, the batch_compression_threshold cannot be modified dynamically if
// the threads count of async-io are changed manually.
if !self.customized && raft_store.store_io_pool_size > 0 {
Copy link
Member

Choose a reason for hiding this comment

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

you can make batch_compression_threshold as Option<..>, then you can know whether it's sepecified

Copy link
Contributor Author

@LykxSassinator LykxSassinator May 7, 2024

Choose a reason for hiding this comment

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

Not appropriate.

make batch_compression_threshold as Option<..>, then you can know whether it's sepecified

If so, we cannot know whether the user forcely disable compression feature in RaftEngine, as the None is used as the default value for batch_compression_threshold. Moreover, RaftEngine also needs a default value with Some(8kb) and it is not compatible to this proposal.

Signed-off-by: lucasliang <nkcs_lykx@hotmail.com>
Signed-off-by: lucasliang <nkcs_lykx@hotmail.com>
src/config/mod.rs Outdated Show resolved Hide resolved
Signed-off-by: lucasliang <nkcs_lykx@hotmail.com>
Copy link
Contributor

@glorv glorv 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 status/LGT2 Status: PR - There are already 2 approvals and removed status/LGT1 Status: PR - There is already 1 approval labels May 8, 2024
@LykxSassinator
Copy link
Contributor Author

/merge

Copy link
Contributor

ti-chi-bot bot commented May 8, 2024

@LykxSassinator: 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.

Copy link
Contributor

ti-chi-bot bot commented May 8, 2024

@LykxSassinator: /merge is only allowed for the committers, you can assign this pull request to the committer in list by filling /assign @committer in the comment to help merge this pull request.

In response to this:

/merge

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.

@LykxSassinator
Copy link
Contributor Author

/merge

Copy link
Contributor

ti-chi-bot bot commented May 8, 2024

@LykxSassinator: 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.

Copy link
Contributor

ti-chi-bot bot commented May 8, 2024

This pull request has been accepted and is ready to merge.

Commit hash: fd36279

@ti-chi-bot ti-chi-bot bot added the status/can-merge Status: Can merge to base branch label May 8, 2024
@ti-chi-bot ti-chi-bot bot merged commit 6f5c642 into tikv:master May 9, 2024
7 checks passed
@ti-chi-bot ti-chi-bot bot added this to the Pool milestone May 9, 2024
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-8.1: #16967.

ti-chi-bot pushed a commit to ti-chi-bot/tikv that referenced this pull request May 9, 2024
ref tikv#16907

Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
ti-chi-bot bot pushed a commit that referenced this pull request May 9, 2024
…ics on it. (#16906) (#16967)

ref #16907

This pr contains:
- Reduce the default compression threshold in RaftEngine to `4kb` as default if users do not manually set it.
- Add relevant metrics on the compression ratio of RaftEngine.write.

Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
Signed-off-by: lucasliang <nkcs_lykx@hotmail.com>

Co-authored-by: lucasliang <nkcs_lykx@hotmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-cherry-pick-release-8.1 release-note size/XXL status/can-merge Status: Can merge to base branch status/LGT2 Status: PR - There are already 2 approvals
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants