proto: add paging_size_bytes to coprocessor.Request#1448
Conversation
48951e0 to
042bfc7
Compare
|
@YuhaoZhang00: adding LGTM is restricted to approvers and reviewers in OWNERS files. DetailsIn response to this: 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-sigs/prow repository. |
042bfc7 to
a6a24f9
Compare
Add a new uint64 field `paging_size_bytes` (field 17) to the coprocessor Request message. When set, TiKV will stop scanning when accumulated scanned bytes reach this limit, enabling byte-budget paging for finer-grained Resource Control. Note: rebased onto upstream master where field 16 is now taken by max_keys_read (pingcap#1450), so paging_size_bytes was bumped from field 16 to field 17. Signed-off-by: JmPotato <github@ipotato.me>
a6a24f9 to
c2edc88
Compare
|
@lhy1024: adding LGTM is restricted to approvers and reviewers in OWNERS files. DetailsIn response to this: 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-sigs/prow repository. |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: cfzjywxk, lhy1024, rleungx, YuhaoZhang00 The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Add a TiDB-side knob `tidb_paging_size_bytes` (global+session sysvar, default 0) and plumb the value end-to-end so it lands as the new `paging_size_bytes` field on `coprocessor.Request`. - `tidb_paging_size_bytes` is allowed in `SET_VAR` hints; default 0 disables byte-budget paging. - The value flows through `DistSQLContext` into `kv.Request.Paging.PagingSizeBytes` via `RequestBuilder`. - In the cop client, `pagingBytesEligible` gates the feature to TiKV + DAG requests. When the byte budget is positive on an eligible request whose row-count paging is disabled, paging is force-enabled with minimum row parameters so the byte budget becomes the dominant page-break signal. This must happen before `checkStoreBatchCopr` because batch copr is incompatible with paging. - The byte budget is carried on each generated `copTask`, populates `coprocessor.Request.PagingSizeBytes` on outgoing RPCs, propagates onto retried tasks (region/lock errors), and is cleared together with `pagingSize` when the small-limit downgrade fires. Dependency: - Pin `pingcap/kvproto` to JmPotato/kvproto demo/ru-paging-size which adds `paging_size_bytes` (tag 17) to `coprocessor.Request` via pingcap/kvproto#1448; revert this replace once that PR is merged and tagged. Tests: - `TestPagingBytesEligible` covers eligibility for TiKV/DAG vs TiFlash and non-DAG requests. - `TestBuildCopTasksWithPagingSizeBytes` covers task construction with and without small-limit downgrade. - `tests/integrationtest/sessionctx/setvar` is extended to cover the new sysvar (default, set, set via SET_VAR hint). Signed-off-by: JmPotato <github@ipotato.me>
Add a TiDB-side knob `tidb_paging_size_bytes` (global+session sysvar, default 0) and plumb the value end-to-end so it lands as the new `paging_size_bytes` field on `coprocessor.Request`. - `tidb_paging_size_bytes` is allowed in `SET_VAR` hints; default 0 disables byte-budget paging. - The value flows through `DistSQLContext` into `kv.Request.Paging.PagingSizeBytes` via `RequestBuilder`. - In the cop client, `pagingBytesEligible` gates the feature to TiKV + DAG requests. When the byte budget is positive on an eligible request whose row-count paging is disabled, paging is force-enabled with minimum row parameters so the byte budget becomes the dominant page-break signal. This must happen before `checkStoreBatchCopr` because batch copr is incompatible with paging. - The byte budget is carried on each generated `copTask`, populates `coprocessor.Request.PagingSizeBytes` on outgoing RPCs, propagates onto retried tasks (region/lock errors), and is cleared together with `pagingSize` when the small-limit downgrade fires. Dependency: - Pin `pingcap/kvproto` to JmPotato/kvproto demo/ru-paging-size which adds `paging_size_bytes` (tag 17) to `coprocessor.Request` via pingcap/kvproto#1448; revert this replace once that PR is merged and tagged. Tests: - `TestPagingBytesEligible` covers eligibility for TiKV/DAG vs TiFlash and non-DAG requests. - `TestBuildCopTasksWithPagingSizeBytes` covers task construction with and without small-limit downgrade. - `tests/integrationtest/sessionctx/setvar` is extended to cover the new sysvar (default, set, set via SET_VAR hint). Signed-off-by: JmPotato <github@ipotato.me>
Add a TiDB-side knob `tidb_paging_size_bytes` (global+session sysvar, default 0) and plumb the value end-to-end so it lands as the new `paging_size_bytes` field on `coprocessor.Request`. - `tidb_paging_size_bytes` is allowed in `SET_VAR` hints; default 0 disables byte-budget paging. - The value flows through `DistSQLContext` into `kv.Request.Paging.PagingSizeBytes` via `RequestBuilder`. - In the cop client, `pagingBytesEligible` gates the feature to TiKV + DAG requests. When the byte budget is positive on an eligible request whose row-count paging is disabled, paging is force-enabled with minimum row parameters so the byte budget becomes the dominant page-break signal. This must happen before `checkStoreBatchCopr` because batch copr is incompatible with paging. - The byte budget is carried on each generated `copTask`, populates `coprocessor.Request.PagingSizeBytes` on outgoing RPCs, propagates onto retried tasks (region/lock errors), and is cleared together with `pagingSize` when the small-limit downgrade fires. Dependency: - Pin `pingcap/kvproto` to JmPotato/kvproto demo/ru-paging-size which adds `paging_size_bytes` (tag 17) to `coprocessor.Request` via pingcap/kvproto#1448; revert this replace once that PR is merged and tagged. Tests: - `TestPagingBytesEligible` covers eligibility for TiKV/DAG vs TiFlash and non-DAG requests. - `TestBuildCopTasksWithPagingSizeBytes` covers task construction with and without small-limit downgrade. - `tests/integrationtest/sessionctx/setvar` is extended to cover the new sysvar (default, set, set via SET_VAR hint). Signed-off-by: JmPotato <github@ipotato.me>
Add a TiDB-side knob `tidb_paging_size_bytes` (global+session sysvar, default 0) and plumb the value end-to-end so it lands as the new `paging_size_bytes` field on `coprocessor.Request`. - `tidb_paging_size_bytes` is allowed in `SET_VAR` hints; default 0 disables byte-budget paging. - The value flows through `DistSQLContext` into `kv.Request.Paging.PagingSizeBytes` via `RequestBuilder`. - In the cop client, `pagingBytesEligible` gates the feature to TiKV + DAG requests. When the byte budget is positive on an eligible request whose row-count paging is disabled, paging is force-enabled with minimum row parameters so the byte budget becomes the dominant page-break signal. This must happen before `checkStoreBatchCopr` because batch copr is incompatible with paging. - The byte budget is carried on each generated `copTask`, populates `coprocessor.Request.PagingSizeBytes` on outgoing RPCs, propagates onto retried tasks (region/lock errors), and is cleared together with `pagingSize` when the small-limit downgrade fires. Dependency: - Pin `pingcap/kvproto` to JmPotato/kvproto demo/ru-paging-size which adds `paging_size_bytes` (tag 17) to `coprocessor.Request` via pingcap/kvproto#1448; revert this replace once that PR is merged and tagged. Tests: - `TestPagingBytesEligible` covers eligibility for TiKV/DAG vs TiFlash and non-DAG requests. - `TestBuildCopTasksWithPagingSizeBytes` covers task construction with and without small-limit downgrade. - `tests/integrationtest/sessionctx/setvar` is extended to cover the new sysvar (default, set, set via SET_VAR hint). Signed-off-by: JmPotato <github@ipotato.me>
Add a TiDB-side knob `tidb_paging_size_bytes` (global+session sysvar, default 0) and plumb the value end-to-end so it lands as the new `paging_size_bytes` field on `coprocessor.Request`. - `tidb_paging_size_bytes` is allowed in `SET_VAR` hints; default 0 disables byte-budget paging. - The value flows through `DistSQLContext` into `kv.Request.Paging.PagingSizeBytes` via `RequestBuilder`. - In the cop client, `pagingBytesEligible` gates the feature to TiKV + DAG requests. When the byte budget is positive on an eligible request whose row-count paging is disabled, paging is force-enabled with minimum row parameters so the byte budget becomes the dominant page-break signal. This must happen before `checkStoreBatchCopr` because batch copr is incompatible with paging. - The byte budget is carried on each generated `copTask`, populates `coprocessor.Request.PagingSizeBytes` on outgoing RPCs, propagates onto retried tasks (region/lock errors), and is cleared together with `pagingSize` when the small-limit downgrade fires. Dependency: - Pin `pingcap/kvproto` to JmPotato/kvproto demo/ru-paging-size which adds `paging_size_bytes` (tag 17) to `coprocessor.Request` via pingcap/kvproto#1448; revert this replace once that PR is merged and tagged. Tests: - `TestPagingBytesEligible` covers eligibility for TiKV/DAG vs TiFlash and non-DAG requests. - `TestBuildCopTasksWithPagingSizeBytes` covers task construction with and without small-limit downgrade. - `tests/integrationtest/sessionctx/setvar` is extended to cover the new sysvar (default, set, set via SET_VAR hint). Signed-off-by: JmPotato <github@ipotato.me>
What is changed and how it works?
Add a new
paging_size_bytesfield (field 17,uint64) to thecoprocessor.Requestmessage.paging_size_bytesis 0, the feature is disabled (backward compatible).Note:
paging_size_bytesis intentionally distinct from the existingmax_keys_read(field 16).max_keys_readis a per-task hard ceiling on storage-engine keys scanned, applied uniformly to any coprocessor request.paging_size_bytesis a paging-only, byte-granularity dimension intended for Resource Control: it bounds the byte volume of a single page so RU pre-charging in PD's resource controller can be performed at byte granularity, complementing the existing row-count-based paging (paging_size). The two fields target different scenarios and may be set independently.Why is this needed?
In concurrent coprocessor workloads under Resource Control, row-count-based paging alone cannot prevent "token cliff" effects where multiple workers exhaust RU budgets simultaneously. A byte-based budget provides finer-grained control for RU pre-charging in PD's resource controller.
Related PRs
tidb_paging_size_bytesontocoprocessor.Request.paging_size_bytes, gated on RC-capped resource group)