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

Add system variable tidb_tso_client_rpc_mode #18726

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

MyonKeminta
Copy link
Contributor

@MyonKeminta MyonKeminta commented Sep 27, 2024

First-time contributors' checklist

What is changed, added or deleted? (Required)

Which TiDB version(s) do your changes apply to? (Required)

Tips for choosing the affected version(s):

By default, CHOOSE MASTER ONLY so your changes will be applied to the next TiDB major or minor releases. If your PR involves a product feature behavior change or a compatibility change, CHOOSE THE AFFECTED RELEASE BRANCH(ES) AND MASTER.

For details, see tips for choosing the affected versions (in Chinese).

  • master (the latest development version)
  • v8.4 (TiDB 8.4 versions)
  • v8.3 (TiDB 8.3 versions)
  • v8.2 (TiDB 8.2 versions)
  • v8.1 (TiDB 8.1 versions)
  • v7.5 (TiDB 7.5 versions)
  • v7.1 (TiDB 7.1 versions)
  • v6.5 (TiDB 6.5 versions)
  • v6.1 (TiDB 6.1 versions)
  • v5.4 (TiDB 5.4 versions)
  • v5.3 (TiDB 5.3 versions)

What is the related PR or file link(s)?

Do your changes match any of the following descriptions?

  • Delete files
  • Change aliases
  • Need modification after applied to another branch
  • Might cause conflicts after applied to another branch

Signed-off-by: MyonKeminta <MyonKeminta@users.noreply.github.com>
Copy link

ti-chi-bot bot commented Sep 27, 2024

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign icemap for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

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 missing-translation-status This PR does not have translation status info. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Sep 27, 2024
@qiancai qiancai added the v8.4 This PR/issue applies to TiDB v8.4. label Sep 27, 2024
@qiancai qiancai self-assigned this Sep 27, 2024
Copy link

ti-chi-bot bot commented Sep 27, 2024

@MyonKeminta: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-verify 1dfdb88 link true /test pull-verify

Full PR test history. Your PR dashboard.

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. I understand the commands that are listed here.

@qiancai qiancai added the translation/doing This PR’s assignee is translating this PR. label Sep 29, 2024
@ti-chi-bot ti-chi-bot bot removed the missing-translation-status This PR does not have translation status info. label Sep 29, 2024
@qiancai qiancai added the area/transaction Indicates that the Issue or PR belongs to the area of transaction. label Sep 29, 2024
@qiancai
Copy link
Collaborator

qiancai commented Sep 29, 2024

@MyonKeminta Please involve a tech reviewer for this PR. Thanks.

@ti-chi-bot ti-chi-bot bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Sep 30, 2024
Copy link

ti-chi-bot bot commented Sep 30, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-09-30 04:11:17.386018303 +0000 UTC m=+241632.806231311: ☑️ agreed by crazycs520.

Comment on lines +5006 to +5008
- `DEFAULT`: 默认的模式。该模式下,TiDB 将当前节点上的所有取 TS 的操作 batch 之后,会串行地对每个 batch 进行发送请求、等待响应的过程。这种模式下,每个取 TS 的操作的平均理论耗时大约是实际 TSO RPC 耗时的 1.5 倍左右。
- `PARALLEL`: 此模式下,TiDB 将尝试将每次攒批的时间缩短到默认模式的大约一半、并尽可能保持两个 TSO RPC 请求在同时进行。在这种模式下,理论上最高可以将每个取 TS 的操作的平均耗时缩短到实际 TSO RPC 耗时的大约 1.25 倍,即默认模式的 83% 左右。但是,batch 的效果会降低,TSO RPC 请求的数量会上升到默认模式的大约两倍左右。
- `PARALLEL-FAST`: 与 `PARALLEL` 模式类似,此模式下,TiDB 将尝试将每次攒批的时间缩短到默认模式的大约 1/4、并尽可能保持 4 个 TSO RPC 请求在同时进行。在这种模式下,理论上最高可以将每个取 TS 的操作的平均耗时缩短到实际 TSO RPC 耗时的大约 1.125 倍,即默认模式的 75% 左右。但是,batch 的效果会降低,TSO RPC 请求的数量会上升到默认模式的大约 4 倍左右。
Copy link
Collaborator

@qiancai qiancai Sep 30, 2024

Choose a reason for hiding this comment

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

Suggested change
- `DEFAULT`: 默认的模式。该模式下,TiDB 将当前节点上的所有取 TS 的操作 batch 之后,会串行地对每个 batch 进行发送请求、等待响应的过程。这种模式下,每个取 TS 的操作的平均理论耗时大约是实际 TSO RPC 耗时的 1.5 倍左右。
- `PARALLEL`: 此模式下,TiDB 将尝试将每次攒批的时间缩短到默认模式的大约一半、并尽可能保持两个 TSO RPC 请求在同时进行。在这种模式下,理论上最高可以将每个取 TS 的操作的平均耗时缩短到实际 TSO RPC 耗时的大约 1.25 ,即默认模式的 83% 左右。但是,batch 的效果会降低,TSO RPC 请求的数量会上升到默认模式的大约两倍左右
- `PARALLEL-FAST`: 与 `PARALLEL` 模式类似,此模式下,TiDB 将尝试将每次攒批的时间缩短到默认模式的大约 1/4并尽可能保持 4 个 TSO RPC 请求在同时进行。在这种模式下,理论上最高可以将每个取 TS 的操作的平均耗时缩短到实际 TSO RPC 耗时的大约 1.125 ,即默认模式的 75% 左右。但是,batch 的效果会降低,TSO RPC 请求的数量会上升到默认模式的大约 4 倍左右。
- `DEFAULT`:默认模式。在该模式下,TiDB 会将一段时间内当前节点的所有取 TS 操作攒批到一个 TSO RPC 请求中发送给 PD 批量获取 TSO,总耗时主要包括攒批时间、TiDB 到 PD 的网络延迟、PD 进行 TSO 分配的耗时等。不同的 TSO RPC 请求之间是串行进行的,每个取 TS 操作的平均耗时是实际 TSO RPC 耗时的 1.5 倍左右。
- `PARALLEL`:并发模式。在该模式下,TiDB 会尝试将每次攒批的时间缩短到默认模式的 1/2 左右,并尽可保持两个 TSO RPC 请求同时进行。这样,每个取 TS 的操作的平均耗时理论上最多能缩短到实际 TSO RPC 耗时的 1.25 倍左右,即默认模式的 83% 左右。但是,攒批的效果会降低,TSO RPC 请求的数量会上升到默认模式的两倍左右
- `PARALLEL-FAST`:快速并发模式。与 `PARALLEL` 模式类似,在该模式下,TiDB 会尝试将每次攒批的时间缩短到默认模式 1/4 左右,并尽可能保持 4 个 TSO RPC 请求同时进行。这样,每个取 TS 操作的平均耗时理论上最多能缩短到实际 TSO RPC 耗时的 1.125 倍左右,即默认模式的 75% 左右。但是,攒批的效果会进一步降低,TSO RPC 请求的数量会上升到默认模式的 4 倍左右。

- 类型:枚举型
- 默认值:`DEFAULT`
- 可选值:`DEFAULT`,`PARALLEL`,`PARALLEL-FAST`
- 这个变量用来设置 TiDB 向 PD 发送 TSO 请求时使用的模式。这里的模式将用于控制 TSO 请求是否并行。可用于调节获取 TS 时消耗在请求攒批阶段的时间,从而在一些场景下降低执行查询时花费在等待 TS 阶段的时间。
Copy link
Collaborator

@qiancai qiancai Sep 30, 2024

Choose a reason for hiding this comment

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

Suggested change
- 这个变量用来设置 TiDB 向 PD 发送 TSO 请求时使用的模式。这里的模式将用于控制 TSO 请求是否并行。可用于调节获取 TS 时消耗在请求攒批阶段的时间,从而在一些场景下降低执行查询时花费在等待 TS 阶段的时间。
- 这个变量用来设置 TiDB 向 PD 发送 TSO RPC 请求时使用的模式。这里的模式将用于控制 TSO RPC 请求是否并行,调节获取 TS 时消耗在请求攒批阶段的时间,从而在一些场景下降低执行查询时花费在等待 TS 阶段的时间。

Comment on lines +5010 to +5017
- 在满足以下条件的情况下,可以考虑将该参数修改到 `PARALLEL` 或 `PARALLEL-FAST` 来获得一定的性能提升:

- 在 SQL 的耗时组成中,TSO wait duration 占比显著。
- PD 的 TSO 分配未达到瓶颈。
- PD 和 TiDB 节点的 CPU 资源比较充足。
- TiDB 到 PD 的网络延迟显著大于 PD 进行 TS 分配的耗时,即 TiDB 往 PD 发起的 TSO 请求的耗时主要由网络延迟构成。
- TiDB 发往 PD 的 TSO 请求的总耗时可以通过 Grafana 的 TiDB 页面中的 PD Client 分类下的 PD TSO RPC Duration 指标进行观察;PD 进行 TS 分配的耗时可以在 Grafana 的 PD 页面中的 TiDB 分类下的 PD server TSO handle duration 进行观察。
- 如果 TiDB 到 PD 的 TSO 请求的数量增加 2 倍(对于 `PARALLEL` 模式)或 4 倍(对于 `PARALLEL-FAST`),所带来的额外网络流量可以接受。
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
- 在满足以下条件的情况下,可以考虑将该参数修改到 `PARALLEL``PARALLEL-FAST` 来获得一定的性能提升:
- 在 SQL 的耗时组成中,TSO wait duration 占比显著
- PD 的 TSO 分配未达到瓶颈。
- PD 和 TiDB 节点的 CPU 资源比较充足。
- TiDB 到 PD 的网络延迟显著大于 PD 进行 TS 分配的耗时,即 TiDB 往 PD 发起的 TSO 请求的耗时主要由网络延迟构成。
- TiDB 发往 PD 的 TSO 请求的总耗时可以通过 Grafana 的 TiDB 页面中的 PD Client 分类下的 PD TSO RPC Duration 指标进行观察;PD 进行 TS 分配的耗时可以在 Grafana 的 PD 页面中的 TiDB 分类下的 PD server TSO handle duration 进行观察
- 如果 TiDB 到 PD 的 TSO 请求的数量增加 2 倍(对于 `PARALLEL` 模式)或 4 倍(对于 `PARALLEL-FAST`),所带来的额外网络流量可以接受。
- 当满足以下条件时,可以考虑将该变量设置为 `PARALLEL``PARALLEL-FAST` 来获得一定的性能提升:
- TSO 等待时间在 SQL 查询的整体耗时中占比较大
- PD 的 TSO 分配未达到瓶颈。
- PD 和 TiDB 节点的 CPU 资源比较充足。
- TiDB 到 PD 的网络延迟显著高于 PD 进行 TSO 分配的耗时,即 TSO RPC 请求的耗时主要由网络延迟构成。
- TSO RPC 请求的耗时可以通过 Grafana 的 TiDB 面板中 PD Client 分类下的 `PD TSO RPC Duration` 指标查看。PD 进行 TSO 分配的耗时可以通过 Grafana 的 PD 面板中 TiDB 分类下的 `PD server TSO handle duration` 指标查看
- 如果 TiDB 到 PD 的 TSO RPC 请求的数量增加 2 倍(对于 `PARALLEL` 模式)或 4 倍(对于 `PARALLEL-FAST`),所带来的额外网络流量可以接受。

Comment on lines +5021 to +5022
> - `PARALLEL`、`PARALLEL-FAST` 模式与 [`tidb_tso_client_batch_max_wait_time`](#tidb_tso_client_batch_max_wait_time-从-v530-版本开始引入) 和 [`tidb_enable_tso_follower_proxy`](#tidb_enable_tso_follower_proxy-从-v530-版本开始引入) 不兼容。如果 [`tidb_tso_client_batch_max_wait_time`](#tidb_tso_client_batch_max_wait_time-从-v530-版本开始引入) 被设为非 0 值或者 [`tidb_enable_tso_follower_proxy`](#tidb_enable_tso_follower_proxy-从-v530-版本开始引入) 被启用,则该变量不生效,并按照 `DEFAULT` 模式工作。
> - `PARALLEL`、`PARALLEL-FAST` 模式针对 TiDB 的取 TS 操作的整体平均耗时进行优化。对于长尾、尖刺问题,启用该优化可能不能带来显著提升。
Copy link
Collaborator

@qiancai qiancai Sep 30, 2024

Choose a reason for hiding this comment

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

Suggested change
> - `PARALLEL``PARALLEL-FAST` 模式与 [`tidb_tso_client_batch_max_wait_time`](#tidb_tso_client_batch_max_wait_time-从-v530-版本开始引入)[`tidb_enable_tso_follower_proxy`](#tidb_enable_tso_follower_proxy-从-v530-版本开始引入) 不兼容。如果 [`tidb_tso_client_batch_max_wait_time`](#tidb_tso_client_batch_max_wait_time-从-v530-版本开始引入) 被设为非 0 值或者 [`tidb_enable_tso_follower_proxy`](#tidb_enable_tso_follower_proxy-从-v530-版本开始引入) 被启用,则该变量不生效,并按照 `DEFAULT` 模式工作。
> - `PARALLEL``PARALLEL-FAST` 模式针对 TiDB 的取 TS 操作的整体平均耗时进行优化。对于长尾、尖刺问题,启用该优化可能不能带来显著提升
> - `PARALLEL``PARALLEL-FAST` 这两种模式与 [`tidb_tso_client_batch_max_wait_time`](#tidb_tso_client_batch_max_wait_time-从-v530-版本开始引入)[`tidb_enable_tso_follower_proxy`](#tidb_enable_tso_follower_proxy-从-v530-版本开始引入) 不兼容。如果 [`tidb_tso_client_batch_max_wait_time`](#tidb_tso_client_batch_max_wait_time-从-v530-版本开始引入) 被设为非零值或者 [`tidb_enable_tso_follower_proxy`](#tidb_enable_tso_follower_proxy-从-v530-版本开始引入) 被启用,则该变量不生效,并按照 `DEFAULT` 模式工作。
> - `PARALLEL``PARALLEL-FAST` 这两种模式主要用于降低 TiDB TS 操作的平均耗时。对于某些延迟波动较大的情况,如长尾、尖刺问题,这两种模式可能不能带来显著的性能提升

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/transaction Indicates that the Issue or PR belongs to the area of transaction. needs-1-more-lgtm Indicates a PR needs 1 more LGTM. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. translation/doing This PR’s assignee is translating this PR. v8.4 This PR/issue applies to TiDB v8.4.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants