-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: MyonKeminta <[email protected]>
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 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 |
@MyonKeminta: The following test failed, say
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. |
@MyonKeminta Please involve a tech reviewer for this PR. Thanks. |
[LGTM Timeline notifier]Timeline:
|
- `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 倍左右。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- `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 阶段的时间。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- 这个变量用来设置 TiDB 向 PD 发送 TSO 请求时使用的模式。这里的模式将用于控制 TSO 请求是否并行。可用于调节获取 TS 时消耗在请求攒批阶段的时间,从而在一些场景下降低执行查询时花费在等待 TS 阶段的时间。 | |
- 这个变量用来设置 TiDB 向 PD 发送 TSO RPC 请求时使用的模式。这里的模式将用于控制 TSO RPC 请求是否并行,调节获取 TS 时消耗在请求攒批阶段的时间,从而在一些场景下降低执行查询时花费在等待 TS 阶段的时间。 |
- 在满足以下条件的情况下,可以考虑将该参数修改到 `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`),所带来的额外网络流量可以接受。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- 在满足以下条件的情况下,可以考虑将该参数修改到 `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`),所带来的额外网络流量可以接受。 |
> - `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 操作的整体平均耗时进行优化。对于长尾、尖刺问题,启用该优化可能不能带来显著提升。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
> - `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 操作的平均耗时。对于某些延迟波动较大的情况,如长尾、尖刺问题,这两种模式可能不能带来显著的性能提升。 |
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).
What is the related PR or file link(s)?
Do your changes match any of the following descriptions?