Skip to content

[improvement](be) Add CPU-aware S3 rate limiter#65420

Open
0AyanamiRei wants to merge 3 commits into
apache:masterfrom
0AyanamiRei:feature/cpu-aware-s3-limiter
Open

[improvement](be) Add CPU-aware S3 rate limiter#65420
0AyanamiRei wants to merge 3 commits into
apache:masterfrom
0AyanamiRei:feature/cpu-aware-s3-limiter

Conversation

@0AyanamiRei

@0AyanamiRei 0AyanamiRei commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Issue Number: None

Related PR: None

Problem Summary:

The original implementation has been replaced with the unified object-storage rate-limiting design accepted after review:

  • A process-wide S3RateLimiterManager owns the GET/PUT QPS and bandwidth buckets independently from S3ClientFactory.
  • Effective per-BE limits are derived from CPU cores. s3_rate_limiter_cpu_cores can explicitly override the value; otherwise Doris combines hardware concurrency with the current cgroup CPU quota. A daemon refreshes the effective limits every 10 seconds so serverless CPU resizing and mutable config changes take effect.
  • RateLimitedObjStorageClient applies admission once per logical top-level operation. Paginated list requests and recursive deletes are therefore charged once instead of once per provider request. GET/PUT mapping is centralized and rejected requests return HTTP 429.
  • Bandwidth limiting reserves at most one second of quota for an IO and refunds unused bytes after a successful short read.
  • Non-cloud deployments wrap all object-storage clients. Cloud deployments wrap only internal-bucket clients.
  • Existing absolute token settings remain the fallback when the new per-core QPS setting is -1; per-core limits support explicit disable and optional maximum caps.

Implementation is based on and adapted from liaoxin01/doris@22f494a3.

Tests add deterministic coverage for config precedence, CPU-aware refresh, limiter state preservation, byte reservation/refund, logical pagination, recursive delete and Azure operation mapping, presigned URL bypass, factory wrapping policy, and full-key client-cache behavior.

Release note

Add CPU-aware GET/PUT QPS and bandwidth rate limiting for BE object-storage requests.

Check List (For Author)

  • Test

    • Regression test
    • Unit Test
      • Targeted BE limiter tests: 28 passed, 1 skipped because the S3 client is disabled locally.
      • BUILD_TYPE=Debug ./build.sh --fe --be -j64
      • build-support/check-format.sh
    • Manual test
    • No need to test or manual test. Explain why:
      • This is a refactor/code format and no logic has been changed.
      • Previous test can cover this change.
      • No code files have been changed.
      • Other reason
  • Behavior changed:

    • No.
    • Yes. CPU-aware QPS and bandwidth limiting are applied at the logical object-storage operation boundary.
  • Does this need documentation?

    • No.
    • Yes.

Check List (For Reviewer who merge this PR)

  • Confirm the release note
  • Confirm test cases
  • Confirm document
  • Add branch pick label

@hello-stephen

Copy link
Copy Markdown
Contributor

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

@0AyanamiRei 0AyanamiRei changed the title [feature](be) Add CPU-aware S3 rate limiter [improvement](be) Add CPU-aware S3 rate limiter Jul 9, 2026
@0AyanamiRei
0AyanamiRei force-pushed the feature/cpu-aware-s3-limiter branch from 5287ce9 to a4effbe Compare July 9, 2026 11:24
@sollhui

sollhui commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

/review

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Found one blocking issue in the S3 bandwidth limiter propagation.

Critical checkpoint conclusions:

  • Goal/test coverage: The PR adds CPU-aware S3 request and byte limiters and BE unit tests for config calculation and dynamic rebuild. It does not fully apply the new byte limiter to every object-storage path that already shares the S3 rate-limiter contract.
  • Scope/focus: The core PR scope is focused on S3 limiter config, S3 client enforcement, and tests.
  • Concurrency/lifecycle: Limiter reset keeps the existing holder locking and atomic update guards; I did not find a separate concurrency issue in the authoritative PR file set.
  • Config/compatibility: The new mutable BE configs are dynamically observed through the existing checker, but the shared Azure path is left incompatible with the new bandwidth limiter behavior.
  • Parallel paths: Native S3 charges bytes for PUT/UploadPart/GetObject; Azure still charges only request count through the same shared limiter gate.
  • Tests/CI: The added unit tests cover S3 effective config and rebuild behavior, but not the Azure parallel path. I could not run BE UTs in this runner because the checkout lacks thirdparty/installed and protoc. git diff --check was clean for the GitHub PR files; check-format.sh could not run because clang-format 16 is unavailable.

User focus: no additional user-provided review focus was supplied.

Comment thread be/src/io/fs/s3_obj_storage_client.cpp Outdated
0AyanamiRei added a commit to 0AyanamiRei/doris that referenced this pull request Jul 10, 2026
### What problem does this PR solve?

Issue Number: N/A

Related PR: apache#65420

Problem Summary: The CPU-aware S3 bandwidth limiter was applied only to the native S3 client. Azure shared the request limiter but did not charge bytes for uploads or downloads, so enabling the limiter produced inconsistent behavior. Centralize request and byte limiter acquisition and pass payload sizes from Azure put, multipart upload, and get operations.

### Release note

Apply object-storage bandwidth limits consistently to native S3 and Azure Blob Storage.

### Check List (For Author)

- Test: Unit Test
    - `S3UTILTest.*`
- Behavior changed: Yes. Azure Blob Storage data transfers now consume the shared byte-rate limiter when S3 rate limiting is enabled.
- Does this need documentation: No
@0AyanamiRei

Copy link
Copy Markdown
Contributor Author

run buildall

@sollhui

sollhui commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

/review

@hello-stephen

Copy link
Copy Markdown
Contributor

Cloud UT Coverage Report

Increment line coverage 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 77.39% (1896/2450)
Line Coverage 64.44% (34064/52862)
Region Coverage 64.87% (17536/27032)
Branch Coverage 54.08% (9404/17390)

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Automated review completed for PR #65420.

I did not find a new blocking issue to submit as an inline comment. The earlier Azure byte-accounting gap is already covered by the existing inline thread discussion_r3557395816, and the current head now routes Azure put_object, upload_part, and get_object payload sizes through the shared acquire_s3_rate_limit path.

Critical checkpoint conclusions:

  • Goal/test proof: the PR adds CPU-aware S3 request limits plus byte-rate limiting and centralizes effective limiter calculation. The added BE unit tests cover absolute/per-core/cap/dynamic-reset cases; I could not complete a local BE UT run in this checkout.
  • Scope: the BE changes are focused around S3/Azure object-storage limiter config, helper propagation, and tests.
  • Concurrency/lifecycle: limiter reset continues to use TokenBucketRateLimiterHolder locks; startup use of CpuInfo::num_cores() is after BE CpuInfo::init(), and the BE test harness also initializes CpuInfo.
  • Config/dynamic behavior: new mutable configs have non-negative validators, and check_s3_rate_limiter_config_changed() observes request and byte limiter changes.
  • Compatibility/parallel paths: native S3 and Azure transfer paths now both use the shared request+byte limiter helper. Cloud recycler has its own config surface and was not changed by this BE-scoped PR.
  • Tests/style: git diff --check is clean. I attempted ./run-be-ut.sh --run --filter='S3UTILTest.*', but interrupted it while it was still bootstrapping dependencies/submodules before reaching test execution.
  • User focus: no additional user-provided focus points.

Subagent conclusions:

  • optimizer-rewrite: no optimizer/Nereids surface and no indirect semantic issue found.
  • tests-session-config: no new tests/config/CI candidate found; existing Azure byte-accounting concern is duplicate-covered and fixed in head.
  • Convergence round 1 ended with both live subagents replying NO_NEW_VALUABLE_FINDINGS for the same final ledger/comment set.

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-H: Total hot run time: 29332 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit 3a87925f6a625fd828c100113a1d320b1f3f8102, data reload: false

------ Round 1 ----------------------------------
============================================
q1	17576	4019	3980	3980
q2	1993	321	203	203
q3	10286	1412	813	813
q4	4722	464	339	339
q5	7739	866	559	559
q6	261	170	135	135
q7	784	839	615	615
q8	10719	1620	1522	1522
q9	6022	4393	4404	4393
q10	6798	1817	1520	1520
q11	506	351	314	314
q12	696	543	421	421
q13	18109	3408	2759	2759
q14	264	264	244	244
q15	q16	781	776	713	713
q17	961	961	945	945
q18	6939	5829	5539	5539
q19	1190	1279	1031	1031
q20	756	664	538	538
q21	5658	2631	2457	2457
q22	414	362	292	292
Total cold run time: 103174 ms
Total hot run time: 29332 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	4315	4263	4222	4222
q2	287	310	230	230
q3	4571	4915	4389	4389
q4	2052	2099	1371	1371
q5	4389	4263	4334	4263
q6	221	173	127	127
q7	1730	2118	1667	1667
q8	2396	2165	2056	2056
q9	7856	7747	7755	7747
q10	4719	4696	4260	4260
q11	548	411	380	380
q12	729	832	540	540
q13	3481	3547	3030	3030
q14	315	300	278	278
q15	q16	706	734	654	654
q17	1336	1310	1308	1308
q18	7992	7435	6863	6863
q19	1085	1044	1109	1044
q20	2202	2198	1932	1932
q21	5156	4512	4729	4512
q22	526	463	400	400
Total cold run time: 56612 ms
Total hot run time: 51273 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-DS: Total hot run time: 180020 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpcds-tools
TPC-DS sf100 test result on commit 3a87925f6a625fd828c100113a1d320b1f3f8102, data reload: false

query5	4318	681	496	496
query6	463	229	186	186
query7	4898	592	347	347
query8	334	191	173	173
query9	8767	4106	4108	4106
query10	469	342	322	322
query11	5857	2333	2150	2150
query12	162	115	107	107
query13	1249	623	441	441
query14	6283	5322	4970	4970
query14_1	4314	4306	4325	4306
query15	217	203	184	184
query16	1077	466	444	444
query17	1147	749	595	595
query18	2579	476	360	360
query19	205	189	155	155
query20	110	108	122	108
query21	236	159	134	134
query22	13680	13599	13361	13361
query23	17397	16587	16084	16084
query23_1	16318	16249	16285	16249
query24	7587	1715	1304	1304
query24_1	1321	1289	1284	1284
query25	548	439	367	367
query26	1325	371	205	205
query27	2631	556	370	370
query28	4408	2030	2004	2004
query29	1045	627	481	481
query30	336	253	217	217
query31	1111	1086	982	982
query32	101	60	60	60
query33	507	314	251	251
query34	1162	1202	644	644
query35	768	778	666	666
query36	1404	1405	1268	1268
query37	150	108	89	89
query38	1872	1678	1651	1651
query39	921	926	893	893
query39_1	898	886	890	886
query40	236	158	142	142
query41	67	62	61	61
query42	94	94	95	94
query43	332	323	278	278
query44	1470	778	781	778
query45	195	185	176	176
query46	1039	1219	755	755
query47	2336	2305	2280	2280
query48	414	401	305	305
query49	570	424	313	313
query50	1054	423	328	328
query51	11031	11028	10846	10846
query52	82	90	72	72
query53	256	276	203	203
query54	283	227	248	227
query55	74	73	65	65
query56	300	279	285	279
query57	1423	1425	1316	1316
query58	291	277	246	246
query59	1583	1606	1399	1399
query60	321	279	265	265
query61	172	168	172	168
query62	702	656	578	578
query63	247	208	209	208
query64	2942	1146	963	963
query65	4857	4804	4782	4782
query66	1860	505	390	390
query67	29593	29402	29429	29402
query68	3160	1607	945	945
query69	396	302	275	275
query70	1057	981	1027	981
query71	366	320	313	313
query72	3111	2476	2362	2362
query73	838	749	407	407
query74	5083	4967	4749	4749
query75	2594	2587	2207	2207
query76	2335	1195	816	816
query77	359	390	277	277
query78	12337	12430	11694	11694
query79	1413	1132	802	802
query80	1297	526	468	468
query81	554	314	286	286
query82	602	153	119	119
query83	362	325	292	292
query84	283	163	133	133
query85	945	575	506	506
query86	423	300	290	290
query87	1823	1830	1733	1733
query88	3825	2812	2804	2804
query89	450	401	366	366
query90	1893	210	192	192
query91	204	189	164	164
query92	63	61	60	60
query93	1721	1555	990	990
query94	715	349	321	321
query95	779	498	548	498
query96	1058	794	370	370
query97	2689	2674	2566	2566
query98	208	210	220	210
query99	1134	1181	1063	1063
Total cold run time: 266118 ms
Total hot run time: 180020 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
ClickBench: Total hot run time: 24.93 s
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/clickbench-tools
ClickBench test result on commit 3a87925f6a625fd828c100113a1d320b1f3f8102, data reload: false

query1	0.00	0.00	0.00
query2	0.09	0.05	0.06
query3	0.25	0.14	0.14
query4	1.62	0.14	0.14
query5	0.25	0.23	0.22
query6	1.27	1.10	1.06
query7	0.04	0.01	0.01
query8	0.06	0.04	0.04
query9	0.38	0.32	0.32
query10	0.60	0.56	0.53
query11	0.19	0.14	0.14
query12	0.18	0.14	0.14
query13	0.47	0.49	0.47
query14	1.02	1.02	1.03
query15	0.62	0.59	0.59
query16	0.31	0.33	0.34
query17	1.10	1.14	1.09
query18	0.22	0.21	0.21
query19	2.05	1.93	1.86
query20	0.02	0.01	0.01
query21	15.44	0.22	0.13
query22	4.92	0.05	0.05
query23	16.13	0.31	0.12
query24	2.90	0.43	0.31
query25	0.11	0.05	0.05
query26	0.73	0.21	0.15
query27	0.04	0.04	0.03
query28	3.54	0.96	0.60
query29	12.50	4.06	3.22
query30	0.28	0.18	0.16
query31	2.77	0.60	0.31
query32	3.22	0.60	0.48
query33	3.26	3.20	3.29
query34	15.64	4.26	3.49
query35	3.54	3.47	3.55
query36	0.55	0.44	0.42
query37	0.09	0.07	0.06
query38	0.05	0.04	0.04
query39	0.04	0.02	0.03
query40	0.18	0.16	0.16
query41	0.08	0.03	0.03
query42	0.04	0.03	0.03
query43	0.04	0.03	0.04
Total cold run time: 96.83 s
Total hot run time: 24.93 s

@0AyanamiRei

Copy link
Copy Markdown
Contributor Author

run buildall

@hello-stephen

Copy link
Copy Markdown
Contributor

Cloud UT Coverage Report

Increment line coverage 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 77.39% (1896/2450)
Line Coverage 64.47% (34079/52862)
Region Coverage 64.89% (17542/27032)
Branch Coverage 54.05% (9399/17390)

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-H: Total hot run time: 29706 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit 5b7b2bd945de7cf00c4367db43d7131666eb9144, data reload: false

------ Round 1 ----------------------------------
============================================
q1	17668	4003	3968	3968
q2	2030	340	218	218
q3	10271	1392	849	849
q4	4682	470	337	337
q5	7582	855	585	585
q6	176	166	135	135
q7	783	854	624	624
q8	9331	1560	1663	1560
q9	5655	4393	4384	4384
q10	6777	1832	1552	1552
q11	513	348	315	315
q12	719	548	427	427
q13	18096	3421	2778	2778
q14	264	255	245	245
q15	q16	788	779	711	711
q17	1032	1002	1007	1002
q18	6876	5964	5546	5546
q19	1318	1306	1093	1093
q20	778	664	558	558
q21	5792	2628	2520	2520
q22	438	361	299	299
Total cold run time: 101569 ms
Total hot run time: 29706 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	4327	4269	4437	4269
q2	289	329	222	222
q3	4567	4924	4451	4451
q4	2051	2145	1354	1354
q5	4462	4294	4341	4294
q6	222	172	128	128
q7	1701	1908	1855	1855
q8	2544	2181	2220	2181
q9	8079	8173	7955	7955
q10	4765	4724	4282	4282
q11	586	415	383	383
q12	759	792	561	561
q13	3204	3539	3000	3000
q14	294	300	276	276
q15	q16	706	738	646	646
q17	1342	1322	1296	1296
q18	8468	7298	7137	7137
q19	1115	1137	1073	1073
q20	2193	2199	1942	1942
q21	5213	4514	4343	4343
q22	538	460	429	429
Total cold run time: 57425 ms
Total hot run time: 52077 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-DS: Total hot run time: 180343 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpcds-tools
TPC-DS sf100 test result on commit 5b7b2bd945de7cf00c4367db43d7131666eb9144, data reload: false

query5	4346	635	492	492
query6	472	239	227	227
query7	4855	611	329	329
query8	352	192	173	173
query9	8790	4157	4120	4120
query10	469	347	294	294
query11	5941	2346	2149	2149
query12	157	104	101	101
query13	1289	628	457	457
query14	6300	5290	4905	4905
query14_1	4266	4279	4282	4279
query15	215	205	190	190
query16	983	456	439	439
query17	923	704	564	564
query18	2423	477	350	350
query19	213	189	148	148
query20	112	108	118	108
query21	232	156	140	140
query22	13624	13565	13413	13413
query23	17387	16672	16197	16197
query23_1	16300	16288	16182	16182
query24	7449	1818	1317	1317
query24_1	1354	1290	1286	1286
query25	528	440	412	412
query26	1344	360	216	216
query27	2584	631	372	372
query28	4560	2036	2028	2028
query29	1088	651	512	512
query30	348	263	231	231
query31	1116	1109	994	994
query32	105	71	74	71
query33	527	343	262	262
query34	1229	1163	665	665
query35	827	780	685	685
query36	1415	1388	1200	1200
query37	159	112	98	98
query38	1874	1705	1667	1667
query39	935	918	902	902
query39_1	879	884	905	884
query40	249	172	150	150
query41	75	72	72	72
query42	98	94	96	94
query43	330	327	279	279
query44	1478	802	781	781
query45	221	196	180	180
query46	1080	1229	747	747
query47	2379	2390	2232	2232
query48	417	432	321	321
query49	593	438	331	331
query50	1074	424	345	345
query51	10596	10714	10559	10559
query52	90	91	77	77
query53	265	288	210	210
query54	304	253	232	232
query55	76	74	74	74
query56	317	295	288	288
query57	1457	1400	1315	1315
query58	303	283	267	267
query59	1619	1663	1451	1451
query60	329	297	265	265
query61	183	176	200	176
query62	686	651	584	584
query63	247	203	206	203
query64	2888	1068	860	860
query65	4852	4761	4766	4761
query66	1819	522	390	390
query67	29521	29324	29402	29324
query68	3404	1519	989	989
query69	438	295	272	272
query70	1081	957	951	951
query71	347	309	313	309
query72	3171	2754	2311	2311
query73	823	779	441	441
query74	5092	4938	4792	4792
query75	2621	2604	2236	2236
query76	2351	1275	759	759
query77	360	395	283	283
query78	12360	12441	11641	11641
query79	1413	1207	784	784
query80	1272	536	454	454
query81	520	322	276	276
query82	616	160	121	121
query83	395	320	294	294
query84	325	162	130	130
query85	1039	627	536	536
query86	429	297	283	283
query87	1842	1848	1747	1747
query88	3763	2836	2823	2823
query89	457	402	361	361
query90	1924	201	191	191
query91	206	193	160	160
query92	66	59	55	55
query93	1583	1574	1029	1029
query94	726	373	323	323
query95	781	582	475	475
query96	1089	838	386	386
query97	2687	2679	2541	2541
query98	213	206	208	206
query99	1139	1191	1028	1028
Total cold run time: 266122 ms
Total hot run time: 180343 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
ClickBench: Total hot run time: 24.98 s
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/clickbench-tools
ClickBench test result on commit 5b7b2bd945de7cf00c4367db43d7131666eb9144, data reload: false

query1	0.01	0.01	0.01
query2	0.09	0.05	0.05
query3	0.26	0.14	0.14
query4	1.61	0.18	0.14
query5	0.23	0.22	0.23
query6	1.26	1.05	1.05
query7	0.04	0.01	0.01
query8	0.06	0.04	0.04
query9	0.38	0.31	0.31
query10	0.60	0.55	0.56
query11	0.19	0.14	0.15
query12	0.19	0.15	0.14
query13	0.48	0.48	0.48
query14	1.01	1.01	0.99
query15	0.64	0.59	0.59
query16	0.31	0.32	0.32
query17	1.12	1.07	1.13
query18	0.22	0.20	0.21
query19	2.07	1.93	1.98
query20	0.02	0.01	0.01
query21	15.40	0.20	0.13
query22	4.95	0.05	0.05
query23	16.14	0.32	0.13
query24	2.96	0.40	0.33
query25	0.11	0.06	0.04
query26	0.74	0.22	0.16
query27	0.04	0.04	0.03
query28	3.53	0.90	0.55
query29	12.51	4.12	3.27
query30	0.28	0.16	0.15
query31	2.77	0.59	0.30
query32	3.21	0.59	0.48
query33	3.26	3.17	3.25
query34	15.64	4.26	3.48
query35	3.54	3.55	3.54
query36	0.56	0.46	0.43
query37	0.09	0.07	0.06
query38	0.05	0.04	0.04
query39	0.04	0.03	0.03
query40	0.19	0.17	0.15
query41	0.08	0.03	0.02
query42	0.03	0.02	0.02
query43	0.04	0.04	0.03
Total cold run time: 96.95 s
Total hot run time: 24.98 s

@hello-stephen

Copy link
Copy Markdown
Contributor

BE UT Coverage Report

Increment line coverage 78.92% (146/185) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 56.91% (23549/41380)
Line Coverage 40.58% (230301/567584)
Region Coverage 36.49% (182038/498929)
Branch Coverage 37.55% (81222/216331)

@0AyanamiRei

Copy link
Copy Markdown
Contributor Author

run buildall

@hello-stephen

Copy link
Copy Markdown
Contributor

Cloud UT Coverage Report

Increment line coverage 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 77.39% (1896/2450)
Line Coverage 64.43% (34059/52862)
Region Coverage 64.87% (17537/27032)
Branch Coverage 54.05% (9400/17390)

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-H: Total hot run time: 29978 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit 52d18cf1612c78d570979bc62a7aa38c0f836201, data reload: false

------ Round 1 ----------------------------------
============================================
q1	17662	4260	4242	4242
q2	2042	337	197	197
q3	10392	1483	870	870
q4	4771	471	343	343
q5	8123	881	587	587
q6	305	179	141	141
q7	845	862	628	628
q8	10576	1673	1611	1611
q9	5848	4428	4407	4407
q10	6692	1793	1515	1515
q11	513	358	325	325
q12	727	579	431	431
q13	18116	3501	2724	2724
q14	269	272	249	249
q15	q16	796	794	712	712
q17	1030	947	1069	947
q18	6964	5999	5668	5668
q19	1193	1371	1041	1041
q20	772	671	591	591
q21	5551	2697	2446	2446
q22	444	368	303	303
Total cold run time: 103631 ms
Total hot run time: 29978 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	4570	4458	4485	4458
q2	320	341	226	226
q3	4612	4993	4401	4401
q4	2243	2240	1424	1424
q5	4531	4403	4877	4403
q6	269	205	142	142
q7	2120	1904	1699	1699
q8	2667	2323	2306	2306
q9	7976	7910	7840	7840
q10	4768	4788	4250	4250
q11	631	467	441	441
q12	778	769	545	545
q13	3288	3733	2976	2976
q14	292	310	259	259
q15	q16	720	752	658	658
q17	1416	1336	1433	1336
q18	8188	7548	6858	6858
q19	1103	1044	1049	1044
q20	2231	2226	1945	1945
q21	5392	4794	4627	4627
q22	529	456	439	439
Total cold run time: 58644 ms
Total hot run time: 52277 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-DS: Total hot run time: 179712 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpcds-tools
TPC-DS sf100 test result on commit 52d18cf1612c78d570979bc62a7aa38c0f836201, data reload: false

query5	4329	631	477	477
query6	451	226	192	192
query7	4884	607	343	343
query8	343	211	175	175
query9	8774	4083	4050	4050
query10	461	346	310	310
query11	5953	2332	2166	2166
query12	155	103	102	102
query13	1289	581	426	426
query14	6270	5274	4930	4930
query14_1	4290	4252	4280	4252
query15	218	202	178	178
query16	1008	505	461	461
query17	1103	706	560	560
query18	2425	457	335	335
query19	209	182	146	146
query20	112	108	106	106
query21	233	147	134	134
query22	13618	13621	13330	13330
query23	17434	16578	16150	16150
query23_1	16339	16236	16240	16236
query24	7689	1801	1284	1284
query24_1	1333	1333	1304	1304
query25	574	470	411	411
query26	1329	337	204	204
query27	2642	587	365	365
query28	4498	2053	2036	2036
query29	1139	628	520	520
query30	348	273	231	231
query31	1123	1115	991	991
query32	111	62	66	62
query33	522	327	266	266
query34	1162	1161	656	656
query35	770	787	713	713
query36	1420	1395	1230	1230
query37	163	112	98	98
query38	1887	1693	1628	1628
query39	921	904	875	875
query39_1	914	876	897	876
query40	248	160	147	147
query41	72	69	68	68
query42	96	91	96	91
query43	322	322	288	288
query44	1420	791	776	776
query45	202	184	179	179
query46	1089	1185	760	760
query47	2438	2328	2203	2203
query48	414	441	306	306
query49	591	452	329	329
query50	1023	434	334	334
query51	10934	10763	10770	10763
query52	87	88	79	79
query53	263	274	207	207
query54	298	261	231	231
query55	75	73	68	68
query56	315	289	289	289
query57	1453	1432	1347	1347
query58	295	270	272	270
query59	1578	1662	1441	1441
query60	314	283	255	255
query61	187	222	149	149
query62	691	650	577	577
query63	235	208	205	205
query64	2855	1034	851	851
query65	4868	4771	4757	4757
query66	1862	509	383	383
query67	29462	29457	29277	29277
query68	3207	1622	997	997
query69	419	309	269	269
query70	1049	990	964	964
query71	352	325	311	311
query72	3030	2797	2380	2380
query73	834	842	453	453
query74	5104	4903	4789	4789
query75	2608	2569	2222	2222
query76	2345	1144	779	779
query77	355	381	291	291
query78	12346	12395	11728	11728
query79	1534	1120	768	768
query80	1265	539	463	463
query81	560	321	290	290
query82	617	155	117	117
query83	353	317	297	297
query84	315	158	131	131
query85	977	579	495	495
query86	431	308	288	288
query87	1816	1826	1754	1754
query88	3777	2822	2778	2778
query89	452	414	364	364
query90	1903	203	202	202
query91	204	190	164	164
query92	64	64	58	58
query93	1789	1493	973	973
query94	729	358	312	312
query95	782	472	468	468
query96	1106	755	378	378
query97	2665	2666	2585	2585
query98	212	202	199	199
query99	1163	1173	1024	1024
Total cold run time: 266915 ms
Total hot run time: 179712 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
ClickBench: Total hot run time: 24.95 s
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/clickbench-tools
ClickBench test result on commit 52d18cf1612c78d570979bc62a7aa38c0f836201, data reload: false

query1	0.01	0.01	0.01
query2	0.09	0.05	0.05
query3	0.26	0.14	0.14
query4	1.61	0.14	0.15
query5	0.25	0.22	0.22
query6	1.24	1.06	1.07
query7	0.04	0.00	0.01
query8	0.06	0.03	0.04
query9	0.37	0.30	0.33
query10	0.55	0.54	0.53
query11	0.19	0.14	0.14
query12	0.18	0.14	0.14
query13	0.46	0.48	0.48
query14	1.03	1.02	1.01
query15	0.61	0.58	0.60
query16	0.32	0.31	0.32
query17	1.12	1.10	1.09
query18	0.23	0.21	0.21
query19	2.02	1.97	1.92
query20	0.02	0.01	0.01
query21	15.43	0.22	0.12
query22	4.86	0.05	0.05
query23	16.16	0.32	0.12
query24	2.90	0.40	0.32
query25	0.12	0.05	0.04
query26	0.74	0.21	0.16
query27	0.05	0.03	0.04
query28	3.49	0.91	0.52
query29	12.54	4.08	3.20
query30	0.28	0.16	0.16
query31	2.77	0.60	0.30
query32	3.22	0.60	0.49
query33	3.25	3.15	3.23
query34	15.51	4.24	3.58
query35	3.51	3.55	3.55
query36	0.54	0.45	0.42
query37	0.09	0.07	0.07
query38	0.06	0.04	0.03
query39	0.04	0.03	0.03
query40	0.18	0.16	0.15
query41	0.08	0.03	0.04
query42	0.04	0.03	0.03
query43	0.05	0.04	0.03
Total cold run time: 96.57 s
Total hot run time: 24.95 s

@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 80.54% (149/185) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 74.79% (30196/40375)
Line Coverage 58.74% (331330/564022)
Region Coverage 55.55% (278228/500825)
Branch Coverage 56.78% (122878/216409)

@0AyanamiRei

Copy link
Copy Markdown
Contributor Author

run buildall

@hello-stephen

Copy link
Copy Markdown
Contributor

BE UT Coverage Report

Increment line coverage 83.71% (370/442) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 57.47% (23967/41707)
Line Coverage 41.17% (235486/572013)
Region Coverage 36.98% (186071/503108)
Branch Coverage 38.14% (83412/218689)

@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 85.50% (342/400) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 75.00% (30510/40681)
Line Coverage 59.13% (336139/568445)
Region Coverage 55.84% (281970/504983)
Branch Coverage 57.09% (124918/218821)

0AyanamiRei added a commit to 0AyanamiRei/doris that referenced this pull request Jul 17, 2026
### What problem does this PR solve?

Issue Number: None

Related PR: apache#65420

Problem Summary: The PR had expanded into a generic runtime config validator redesign and AWS SDK retry-boundary throttling. Keep this PR scoped to the CPU-aware object-storage limiter by restoring the existing config framework and signed-handler behavior, documenting the runtime validator limitation for a separate PR, and keeping limiter tests independent of generic set_config validation.

### Release note

None

### Check List (For Author)

- Test: Unit Test
    - ./run-be-ut.sh --run --filter=ConfigTest.*:S3UTILTest.*:S3ObjStorageClientMockTest.* -j8
    - ./build.sh --be -j64
    - ./build-support/check-format.sh
- Behavior changed: Yes. Revert the out-of-scope config framework and retry-boundary changes.
- Does this need documentation: No
@0AyanamiRei

Copy link
Copy Markdown
Contributor Author

run buildall

0AyanamiRei added a commit to 0AyanamiRei/doris that referenced this pull request Jul 17, 2026
### What problem does this PR solve?

Issue Number: None

Related PR: apache#65420

Problem Summary: The previous rollback removed the AWS pre-sign retry hook but left per-attempt byte accounting in both Native S3 and Azure. Restore the pre-retry design so each Doris logical GET or PUT request acquires QPS and bytes once before entering the SDK. Remove AWS signed handlers, Azure per-retry policies, SDK request parsing, split limiter acquisition APIs, and per-attempt tests. Add focused tests for the logical-request boundary.

### Release note

None

### Check List (For Author)

- Test: Unit Test
    - ./run-be-ut.sh --run --filter=S3ObjStorageClientMockTest.*:AzureObjStorageClientRateLimiterTest.*:S3UTILTest.* -j64
    - ./build.sh --be -j64
    - ./build-support/check-format.sh
- Behavior changed: Yes. Object-storage bytes are charged once per Doris logical request instead of once per SDK retry attempt.
- Does this need documentation: No
@0AyanamiRei

Copy link
Copy Markdown
Contributor Author

run buildall

@hello-stephen

Copy link
Copy Markdown
Contributor

Cloud UT Coverage Report

Increment line coverage 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 77.59% (1908/2459)
Line Coverage 64.48% (34155/52971)
Region Coverage 64.91% (17576/27079)
Branch Coverage 54.05% (9420/17428)

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-H: Total hot run time: 29282 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit d538f615395f32a065cc15bc5c7de0515b8f2543, data reload: false

------ Round 1 ----------------------------------
============================================
q1	18002	4209	4067	4067
q2	2039	326	207	207
q3	10275	1415	829	829
q4	4711	472	338	338
q5	7770	900	574	574
q6	275	184	146	146
q7	794	839	614	614
q8	10457	1606	1568	1568
q9	5911	4357	4358	4357
q10	6744	1784	1495	1495
q11	516	377	322	322
q12	751	573	454	454
q13	18131	3426	2772	2772
q14	267	260	236	236
q15	q16	784	774	712	712
q17	1006	919	860	860
q18	6884	5755	5488	5488
q19	1163	1336	1114	1114
q20	822	671	575	575
q21	5653	2630	2251	2251
q22	441	353	303	303
Total cold run time: 103396 ms
Total hot run time: 29282 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	4440	4438	4442	4438
q2	307	323	218	218
q3	4643	4971	4429	4429
q4	2088	2152	1375	1375
q5	4444	4333	4278	4278
q6	226	177	131	131
q7	2175	1850	1633	1633
q8	2675	2275	2228	2228
q9	7856	7829	7800	7800
q10	4712	4613	4189	4189
q11	773	427	412	412
q12	750	744	548	548
q13	3295	3688	2973	2973
q14	316	302	272	272
q15	q16	702	749	667	667
q17	1382	1389	1380	1380
q18	8094	7363	7035	7035
q19	1118	1091	1111	1091
q20	2236	2192	1946	1946
q21	5322	4687	4531	4531
q22	519	465	412	412
Total cold run time: 58073 ms
Total hot run time: 51986 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-DS: Total hot run time: 176978 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpcds-tools
TPC-DS sf100 test result on commit d538f615395f32a065cc15bc5c7de0515b8f2543, data reload: false

query5	4337	630	476	476
query6	478	214	205	205
query7	4841	580	348	348
query8	340	200	173	173
query9	8785	4059	4047	4047
query10	477	361	314	314
query11	5923	2338	2145	2145
query12	157	104	105	104
query13	1250	617	412	412
query14	6361	5271	4878	4878
query14_1	4236	4241	4223	4223
query15	225	208	179	179
query16	1052	500	454	454
query17	1133	718	590	590
query18	2731	474	352	352
query19	221	196	150	150
query20	116	107	112	107
query21	245	162	141	141
query22	13594	13564	13351	13351
query23	17323	16353	16097	16097
query23_1	16235	16177	16153	16153
query24	7513	1787	1279	1279
query24_1	1324	1247	1274	1247
query25	565	457	399	399
query26	1093	356	207	207
query27	2589	638	370	370
query28	4409	1979	1965	1965
query29	1094	632	488	488
query30	344	265	229	229
query31	1125	1098	972	972
query32	111	64	61	61
query33	536	330	255	255
query34	1169	1126	635	635
query35	776	782	682	682
query36	1206	1227	1055	1055
query37	155	114	93	93
query38	1873	1689	1686	1686
query39	885	885	845	845
query39_1	859	845	844	844
query40	253	167	153	153
query41	72	70	68	68
query42	138	92	91	91
query43	321	327	280	280
query44	1413	770	750	750
query45	197	181	181	181
query46	1074	1191	720	720
query47	2157	2129	1997	1997
query48	414	423	294	294
query49	570	423	321	321
query50	1033	431	350	350
query51	10519	10736	10532	10532
query52	92	86	72	72
query53	257	282	204	204
query54	291	228	222	222
query55	75	77	69	69
query56	294	288	280	280
query57	1322	1293	1190	1190
query58	282	274	280	274
query59	1587	1665	1396	1396
query60	306	271	252	252
query61	145	148	153	148
query62	554	491	427	427
query63	233	199	196	196
query64	2628	1049	830	830
query65	4597	4632	4619	4619
query66	1760	509	387	387
query67	29219	29107	29093	29093
query68	3285	1677	916	916
query69	402	312	272	272
query70	1044	948	957	948
query71	365	342	303	303
query72	3099	2749	2382	2382
query73	843	722	444	444
query74	5094	4928	4731	4731
query75	2525	2492	2150	2150
query76	2338	1147	754	754
query77	344	366	278	278
query78	11895	11881	11235	11235
query79	1398	1108	725	725
query80	1231	542	477	477
query81	517	344	290	290
query82	621	155	119	119
query83	362	323	298	298
query84	287	162	133	133
query85	993	593	517	517
query86	447	314	275	275
query87	1822	1809	1773	1773
query88	3701	2775	2726	2726
query89	435	377	326	326
query90	1899	196	192	192
query91	204	193	159	159
query92	67	59	54	54
query93	1721	1499	1047	1047
query94	737	353	333	333
query95	788	586	473	473
query96	1136	767	328	328
query97	2610	2628	2493	2493
query98	220	206	202	202
query99	1093	1109	981	981
Total cold run time: 263422 ms
Total hot run time: 176978 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
ClickBench: Total hot run time: 24.85 s
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/clickbench-tools
ClickBench test result on commit d538f615395f32a065cc15bc5c7de0515b8f2543, data reload: false

query1	0.00	0.00	0.01
query2	0.10	0.05	0.04
query3	0.26	0.16	0.14
query4	1.60	0.14	0.14
query5	0.24	0.22	0.24
query6	1.28	1.04	1.08
query7	0.04	0.01	0.00
query8	0.06	0.03	0.03
query9	0.37	0.31	0.33
query10	0.56	0.57	0.57
query11	0.20	0.14	0.14
query12	0.18	0.14	0.14
query13	0.47	0.47	0.48
query14	1.00	1.03	0.99
query15	0.62	0.60	0.58
query16	0.31	0.32	0.30
query17	1.12	1.11	1.08
query18	0.22	0.21	0.22
query19	2.06	1.92	1.97
query20	0.01	0.01	0.01
query21	15.43	0.24	0.14
query22	4.73	0.06	0.05
query23	16.11	0.30	0.12
query24	2.95	0.40	0.35
query25	0.09	0.05	0.05
query26	0.76	0.20	0.16
query27	0.05	0.03	0.04
query28	3.51	0.97	0.54
query29	12.57	3.97	3.17
query30	0.27	0.16	0.15
query31	2.77	0.61	0.30
query32	3.23	0.60	0.48
query33	3.15	3.20	3.20
query34	15.63	4.21	3.47
query35	3.46	3.49	3.51
query36	0.55	0.46	0.43
query37	0.09	0.07	0.07
query38	0.06	0.04	0.04
query39	0.04	0.03	0.03
query40	0.19	0.16	0.15
query41	0.08	0.03	0.03
query42	0.04	0.03	0.03
query43	0.05	0.04	0.04
Total cold run time: 96.51 s
Total hot run time: 24.85 s

…decorator

Redesign the S3 GET/PUT rate limiting path:

- New configs s3_{get,put}_qps_per_core / _qps_max and
  s3_{get,put}_bytes_per_second_per_core / _max derive per-BE limits from
  CPU cores (cgroup-quota aware), so heterogeneous BEs get proportional
  budgets. -1 keeps the legacy absolute token configs bit-for-bit.
- All rate limiting now lives in one decorator, RateLimitedObjStorageClient,
  wrapped by S3ClientFactory at construction time. Provider clients (S3,
  Azure, future GCP) contain no rate limiting code anymore.
- In cloud mode only internal storage-vault buckets are limited; external
  buckets (S3 load, TVF, external catalogs) get the bare client. Non-cloud
  mode wraps every client, preserving legacy behavior.
- New bytes-per-second buckets charge payload size with reserve+settle
  accounting: short reads are refunded, single reservations are clamped to
  1s of bandwidth, and the guard pins the exact bucket generation it charged
  so a concurrent limiter reset cannot make the refund pollute a fresh
  bucket. The derived per-BE bytes/s should not be set below the single IO
  upper bound per second (s3_write_buffer_size); documented on the configs.
- S3RateLimiterManager::refresh() is idempotent and driven by a daemon
  thread, picking up both dynamic config changes (now effective in non-cloud
  mode too) and in-place cgroup CPU resizes for serverless BEs; a positive
  s3_rate_limiter_cpu_cores overrides detection for control-plane pushes.
- Fix S3 client cache and ObjClientHolder::reset treating get_hash()
  equality as configuration identity (XOR of crc32s collides easily).
- Fix TokenBucketRateLimiterHolder sleeping while holding the read lock,
  which blocked reset() for the whole throttle duration.
@0AyanamiRei 0AyanamiRei reopened this Jul 19, 2026
### What problem does this PR solve?

Issue Number: None

Related PR: apache#65420

Problem Summary: After adopting the unified object-storage rate limiter implementation, deterministic coverage was needed for refresh state, CPU-based resizing, reservation settlement, logical pagination and operation mapping, factory wrapping policy, and full-key client cache behavior. This change adds that coverage, removes wall-clock-sensitive assertions, and makes dynamic config restoration safe on early test exits.

### Release note

None

### Check List (For Author)

- Test: Unit Test / Build
    - Targeted BE unit tests: 28 passed, 1 skipped because the S3 client is disabled locally
    - BUILD_TYPE=Debug ./build.sh --fe --be -j64
    - build-support/check-format.sh
    - Debug BE UT objects compiled; final link is blocked by the pre-existing unresolved __lsan_disable/__lsan_enable references in cached_remote_file_reader_peer_test.cpp
- Behavior changed: No. Test coverage only.
- Does this need documentation: No
@0AyanamiRei
0AyanamiRei force-pushed the feature/cpu-aware-s3-limiter branch from d538f61 to a12fe2e Compare July 20, 2026 01:50
@0AyanamiRei

Copy link
Copy Markdown
Contributor Author

run buildall

@sollhui

sollhui commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

/review

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Request changes: five correctness issues remain in the new limiter path: provider-request QPS is no longer bounded for pagination/batching, a permanent local rejection is mislabeled as retryable 429, oversized I/O bytes are dropped from accounting, token refill/refund ordering permits excess bursts, and refresh can split one reservation across two limiter generations.

Critical checkpoint conclusions:

  • Goal and proof: The PR centralizes CPU-aware GET/PUT QPS and bandwidth limiting for S3/Azure, adds dynamic refresh, and distinguishes cloud-internal clients. The manager/decorator/factory structure implements that shape, but the five issues above mean it does not yet enforce the advertised limits correctly. The unit tests cover config resolution, refresh, wrapping, cache identity, provider mapping, and refund mechanics, but some tests codify the defective logical-call/clamp semantics and do not prove production traffic bounds.
  • Scope and clarity: The change is focused on object-storage rate limiting and mostly reuses one decorator/manager abstraction. No unrelated source change was found.
  • Concurrency: I traced I/O workers racing the daemon refresh through holder shared mutexes, per-bucket spinlocks, and pinned shared pointers. No deadlock, UAF, or unnecessarily heavy operation under a lock was found, but the separate get_max_speed() and charge() snapshots create the reported cross-generation race. The previously reported retired-generation debt issue remains real and was not duplicated here.
  • Lifecycle: Daemon startup/stop and singleton/holder lifetimes terminate cleanly; no circular ownership, shutdown hazard, or cross-TU static-initialization dependency was found.
  • Configuration and compatibility: Mutable limits are refreshed and the legacy absolute settings remain a fallback, but valid low bandwidth settings contradict the unenforced single-I/O assumption, and moving fallback QPS admission from provider calls to logical calls changes existing behavior. No wire/storage format or rolling-upgrade compatibility boundary is changed.
  • Parallel paths and conditions: S3 and Azure construction, cloud vault create/reset, external-client exclusion, cache equality/hash, and non-cloud wrapping were traced. Internal/external classification is complete, but S3/Azure list pages, recursive-delete GET/PUT calls, Azure batches, and Azure's no-op multipart-create path are not accounted at actual request boundaries.
  • Tests and expected results: No regression-result files change. Missing negative/concurrency coverage is called out inline: real provider page/batch counts, reader-level hard rejection, I/O larger than one second of quota, controllable-clock idle/refund cases, and barrier tests across rate refresh.
  • Observability and error handling: Throttle logs and bvar metrics exist and are lightweight enough. The local hard rejection's 429 mapping is incorrect and also pollutes provider-throttle retry/metrics behavior; no other unchecked status or exception-boundary issue was found.
  • Transactions, persistence, data writes, and FE/BE propagation: No EditLog, transaction protocol, persistent metadata, FE/BE field propagation, nullable-column, or allocator-sensitive ownership change is involved. Object writes remain delegated to the provider clients; the defects concern admission/timing rather than storage atomicity.
  • Performance: Disabled-holder fast paths are present, but the 429 mapping can cause futile exponential backoff, the refresh race can cause very long oversleeps, and logical-call QPS can generate provider bursts. No additional CPU/memory complexity issue survived review.
  • Other/user focus: Existing comments about SDK retry-byte accounting, reset debt, CPU-source selection, and signing order were deduplicated. No additional user focus was supplied.

Validation was static only, as required by this review runner; I did not build or run tests. At submission time, formatter, license, large-file, FE UT, and Cloud UT checks pass; BE UT, compile, performance, and this code-review check are still pending.

Comment thread be/src/io/fs/rate_limited_obj_storage_client.h
Comment thread be/src/io/fs/rate_limited_obj_storage_client.cpp
Comment thread be/src/util/s3_rate_limiter_manager.cpp
Comment thread common/cpp/token_bucket_rate_limiter.cpp Outdated
Comment thread be/src/util/s3_rate_limiter_manager.cpp
@hello-stephen

Copy link
Copy Markdown
Contributor

BE UT Coverage Report

Increment line coverage 81.56% (230/282) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 57.55% (24016/41729)
Line Coverage 41.25% (236189/572556)
Region Coverage 37.09% (186760/503535)
Branch Coverage 38.29% (83894/219122)

@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 83.28% (244/293) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 74.94% (30505/40706)
Line Coverage 59.08% (336202/569039)
Region Coverage 55.74% (281715/505450)
Branch Coverage 57.04% (125076/219270)

### What problem does this PR solve?

Issue Number: None

Related PR: apache#65420

Problem Summary: The S3 byte limiter could admit an unbounded amount of reserved work. Each admitted request added token debt before sleeping, so bursts could produce progressively longer waits while occupying object-storage worker threads. This change reuses the limiter count as the outstanding byte reservation, caps it at one second of effective bandwidth, atomically rolls back rejected charges, and separates short-read token settlement from request-completion count release.

### Release note

Bound outstanding S3 byte-rate reservations to prevent unbounded limiter waits.

### Check List (For Author)

- Test: Unit Test
    - ./run-be-ut.sh --run --filter=TokenBucketRateLimiterTest.*:S3RateLimiterManagerTest.*:S3RateLimitGuardTest.*:RateLimitedObjStorageClientTest.* -j48
- Behavior changed: Yes. S3 byte reservations exceeding one second of effective bandwidth are rejected without leaving byte-token or count debt.
- Does this need documentation: No
@0AyanamiRei

Copy link
Copy Markdown
Contributor Author

run buildall

@hello-stephen

Copy link
Copy Markdown
Contributor

Cloud UT Coverage Report

Increment line coverage 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 77.50% (1908/2462)
Line Coverage 64.45% (34158/52999)
Region Coverage 64.85% (17570/27093)
Branch Coverage 54.04% (9423/17438)

@hello-stephen

Copy link
Copy Markdown
Contributor

BE UT Coverage Report

Increment line coverage 82.82% (241/291) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 57.56% (24024/41737)
Line Coverage 41.27% (236328/572688)
Region Coverage 37.10% (186838/503659)
Branch Coverage 38.30% (83961/219197)

@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 84.44% (255/302) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 75.58% (30772/40714)
Line Coverage 59.94% (341188/569171)
Region Coverage 57.13% (288846/505574)
Branch Coverage 58.41% (128115/219345)

@0AyanamiRei

Copy link
Copy Markdown
Contributor Author

run buildall

@sollhui

sollhui commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

/review

@github-actions

Copy link
Copy Markdown
Contributor

Codex automated review failed and did not complete.

Error: You've hit your usage limit. Visit https://chatgpt.com/codex/settings/usage to purchase more credits or try again at Jul 25th, 2026 3:35 AM.
Workflow run: https://github.com/apache/doris/actions/runs/29753648553

Please inspect the workflow logs and rerun the review after the underlying issue is resolved.

@hello-stephen

Copy link
Copy Markdown
Contributor

BE UT Coverage Report

Increment line coverage 82.82% (241/291) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 57.56% (24024/41737)
Line Coverage 41.27% (236336/572688)
Region Coverage 37.09% (186808/503659)
Branch Coverage 38.31% (83968/219197)

@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 84.44% (255/302) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 75.58% (30772/40714)
Line Coverage 59.95% (341192/569171)
Region Coverage 57.13% (288823/505574)
Branch Coverage 58.41% (128120/219345)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants