Skip to content

Conversation

@mymeiyi
Copy link
Contributor

@mymeiyi mymeiyi commented Jan 8, 2026

What problem does this PR solve?

Issue Number: close #xxx

Related PR: #xxx

Problem Summary:

Release note

None

Check List (For Author)

  • Test

    • Regression test
    • Unit Test
    • Manual test (add detailed scripts or steps below)
    • 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.
  • 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

Copilot AI review requested due to automatic review settings January 8, 2026 10:54
@hello-stephen
Copy link
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?

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the TabletInvertedIndex class to reduce memory usage in cloud mode by splitting it into two implementations: LocalTabletInvertedIndex for local deployments and CloudTabletInvertedIndex for cloud deployments. The key memory optimization is that CloudTabletInvertedIndex stores only one replica per tablet (using a simple Map) instead of tracking multiple replicas per backend (using a Table), since cloud mode doesn't need backend-specific replica tracking.

Key Changes

  • Converted TabletInvertedIndex to an abstract base class with abstract methods for replica management
  • Created LocalTabletInvertedIndex with the original implementation supporting multiple replicas per tablet with backend associations
  • Created CloudTabletInvertedIndex with a simplified implementation storing one replica per tablet without backend tracking
  • Added factory methods to EnvFactory and CloudEnvFactory to instantiate the appropriate implementation based on deployment mode

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
TabletInvertedIndex.java Converted to abstract class, removed concrete replica management logic, made several methods throw UnsupportedOperationException for cloud mode
LocalTabletInvertedIndex.java New class containing the original TabletInvertedIndex implementation for local deployments with full backend-aware replica tracking
CloudTabletInvertedIndex.java New lightweight class for cloud mode storing one replica per tablet without backend associations
EnvFactory.java Added createTabletInvertedIndex() factory method returning LocalTabletInvertedIndex
CloudEnvFactory.java Added createTabletInvertedIndex() factory method returning CloudTabletInvertedIndex
Env.java Updated to use factory method instead of direct instantiation
Test files (8 files) Updated to use LocalTabletInvertedIndex instead of direct TabletInvertedIndex instantiation
ClusterLoadStatisticsTest.java Incorrectly changed to use CloudTabletInvertedIndex
Comments suppressed due to low confidence (1)

fe/fe-core/src/test/java/org/apache/doris/clone/ClusterLoadStatisticsTest.java:165

  • This test is using CloudTabletInvertedIndex but adding multiple replicas per tablet (lines 155-157, 160-161, 164-165). CloudTabletInvertedIndex is designed to store only one replica per tablet (using Map instead of Table), so calling addReplica multiple times for the same tablet will overwrite previous replicas. This test should be using LocalTabletInvertedIndex instead, or the test needs to be updated to match cloud mode semantics where there's only one replica per tablet.
        invertedIndex = new CloudTabletInvertedIndex();

        invertedIndex.addTablet(50000, new TabletMeta(1, 2, 3, 4, 5, TStorageMedium.HDD));
        invertedIndex.addReplica(50000, new LocalReplica(50001, be1.getId(), 0, ReplicaState.NORMAL));
        invertedIndex.addReplica(50000, new LocalReplica(50002, be2.getId(), 0, ReplicaState.NORMAL));
        invertedIndex.addReplica(50000, new LocalReplica(50003, be3.getId(), 0, ReplicaState.NORMAL));

        invertedIndex.addTablet(60000, new TabletMeta(1, 2, 3, 4, 5, TStorageMedium.HDD));
        invertedIndex.addReplica(60000, new LocalReplica(60002, be2.getId(), 0, ReplicaState.NORMAL));
        invertedIndex.addReplica(60000, new LocalReplica(60003, be3.getId(), 0, ReplicaState.NORMAL));

        invertedIndex.addTablet(70000, new TabletMeta(1, 2, 3, 4, 5, TStorageMedium.HDD));
        invertedIndex.addReplica(70000, new LocalReplica(70002, be2.getId(), 0, ReplicaState.NORMAL));
        invertedIndex.addReplica(70000, new LocalReplica(70003, be3.getId(), 0, ReplicaState.NORMAL));

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@mymeiyi mymeiyi force-pushed the fix-fe-inverted-index branch from acd9b13 to 85e8126 Compare January 8, 2026 11:22
@mymeiyi
Copy link
Contributor Author

mymeiyi commented Jan 8, 2026

run buildall

@doris-robot
Copy link

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

------ Round 1 ----------------------------------
q1	17605	4164	4031	4031
q2	2054	370	246	246
q3	10115	1292	736	736
q4	10206	817	315	315
q5	7508	2118	1843	1843
q6	190	177	144	144
q7	954	819	676	676
q8	9281	1416	1106	1106
q9	5135	4533	4626	4533
q10	6795	1821	1402	1402
q11	527	303	301	301
q12	723	757	617	617
q13	17779	3931	3127	3127
q14	292	307	288	288
q15	588	528	507	507
q16	731	680	639	639
q17	668	847	484	484
q18	6559	6441	6988	6441
q19	1147	1042	627	627
q20	430	387	277	277
q21	3297	2751	2608	2608
q22	1149	1072	1019	1019
Total cold run time: 103733 ms
Total hot run time: 31967 ms

----- Round 2, with runtime_filter_mode=off -----
q1	4473	4333	4302	4302
q2	330	413	329	329
q3	2233	2863	2474	2474
q4	1438	1846	1461	1461
q5	4386	4202	4409	4202
q6	213	167	130	130
q7	1929	1925	1776	1776
q8	2535	2552	2350	2350
q9	7223	7059	7192	7059
q10	2432	2632	2393	2393
q11	540	469	453	453
q12	721	780	646	646
q13	3594	4138	3321	3321
q14	281	284	257	257
q15	524	491	486	486
q16	636	659	621	621
q17	1114	1386	1301	1301
q18	7465	7366	7250	7250
q19	833	787	800	787
q20	1878	1944	1874	1874
q21	4535	4177	4153	4153
q22	1039	1046	953	953
Total cold run time: 50352 ms
Total hot run time: 48578 ms

@doris-robot
Copy link

TPC-DS: Total hot run time: 172330 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 85e8126e45c4c9e956618818eca49d344de3bfb4, data reload: false

query5	4741	593	451	451
query6	346	238	231	231
query7	4229	455	270	270
query8	338	248	241	241
query9	8771	2670	2692	2670
query10	535	383	327	327
query11	15338	15048	14802	14802
query12	187	116	113	113
query13	1260	496	368	368
query14	6707	3016	2766	2766
query14_1	2666	2642	2689	2642
query15	203	193	179	179
query16	999	474	473	473
query17	1088	704	581	581
query18	2711	432	347	347
query19	231	224	199	199
query20	125	116	117	116
query21	214	143	125	125
query22	3817	4003	3988	3988
query23	16110	15591	15289	15289
query23_1	15595	15477	15303	15303
query24	7266	1564	1161	1161
query24_1	1189	1173	1225	1173
query25	559	474	425	425
query26	1256	269	158	158
query27	2738	463	299	299
query28	4447	2155	2138	2138
query29	817	562	520	520
query30	319	239	210	210
query31	800	626	555	555
query32	82	67	68	67
query33	534	346	310	310
query34	937	901	530	530
query35	729	759	680	680
query36	866	910	840	840
query37	128	94	82	82
query38	2694	2686	2691	2686
query39	778	751	730	730
query39_1	718	713	705	705
query40	220	131	116	116
query41	69	63	61	61
query42	108	105	105	105
query43	453	429	458	429
query44	1357	734	720	720
query45	194	196	178	178
query46	845	970	588	588
query47	1433	1456	1299	1299
query48	301	324	245	245
query49	644	415	336	336
query50	634	271	198	198
query51	3800	3794	3821	3794
query52	110	112	97	97
query53	300	325	274	274
query54	291	260	244	244
query55	79	72	71	71
query56	290	295	292	292
query57	1020	988	951	951
query58	270	253	254	253
query59	2142	2088	2116	2088
query60	316	315	299	299
query61	162	160	157	157
query62	389	351	313	313
query63	303	268	276	268
query64	4889	1299	980	980
query65	3775	3745	3644	3644
query66	1381	407	297	297
query67	14831	14871	15850	14871
query68	5390	1016	751	751
query69	485	341	302	302
query70	1054	951	894	894
query71	352	305	270	270
query72	5988	3354	3431	3354
query73	759	726	299	299
query74	8756	8691	8528	8528
query75	2831	2797	2447	2447
query76	3979	1073	657	657
query77	529	369	289	289
query78	9768	9667	9142	9142
query79	1616	904	595	595
query80	1370	559	473	473
query81	552	258	226	226
query82	415	139	107	107
query83	268	251	243	243
query84	271	113	104	104
query85	916	509	456	456
query86	462	322	284	284
query87	2892	2828	2728	2728
query88	3200	2212	2197	2197
query89	396	348	332	332
query90	1975	150	149	149
query91	168	161	140	140
query92	69	67	62	62
query93	1376	908	528	528
query94	633	333	298	298
query95	583	366	298	298
query96	569	459	204	204
query97	2296	2391	2272	2272
query98	222	195	195	195
query99	628	583	499	499
Total cold run time: 253870 ms
Total hot run time: 172330 ms

@mymeiyi
Copy link
Contributor Author

mymeiyi commented Jan 8, 2026

run cloud_p0

@hello-stephen
Copy link
Contributor

FE Regression Coverage Report

Increment line coverage 44.60% (227/509) 🎉
Increment coverage report
Complete coverage report

@dataroaring dataroaring changed the title [fix](fe) modify TabletInvertedIndex to local and cloud to reduce memory [opt](fe) modify TabletInvertedIndex to local and cloud to reduce memory Jan 8, 2026
@mymeiyi mymeiyi force-pushed the fix-fe-inverted-index branch from 85e8126 to 776f407 Compare January 9, 2026 02:51
@mymeiyi
Copy link
Contributor Author

mymeiyi commented Jan 9, 2026

run buildall

Copy link
Contributor

@deardeng deardeng left a comment

Choose a reason for hiding this comment

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

LGTM

@github-actions
Copy link
Contributor

github-actions bot commented Jan 9, 2026

PR approved by anyone and no changes requested.

@doris-robot
Copy link

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

------ Round 1 ----------------------------------
q1	17586	4200	4019	4019
q2	1995	354	239	239
q3	10177	1262	691	691
q4	10221	914	331	331
q5	7532	2107	1827	1827
q6	197	176	144	144
q7	909	818	669	669
q8	9233	1398	1167	1167
q9	4973	4525	4487	4487
q10	6730	1799	1417	1417
q11	518	300	277	277
q12	702	753	607	607
q13	17769	3831	3155	3155
q14	299	303	282	282
q15	600	520	509	509
q16	700	702	648	648
q17	687	878	533	533
q18	7075	6466	6335	6335
q19	1117	974	607	607
q20	407	363	252	252
q21	3075	2505	2329	2329
q22	1031	1010	949	949
Total cold run time: 103533 ms
Total hot run time: 31474 ms

----- Round 2, with runtime_filter_mode=off -----
q1	4083	4036	4049	4036
q2	346	414	332	332
q3	2082	2602	2259	2259
q4	1351	1782	1316	1316
q5	4070	4030	4058	4030
q6	215	173	130	130
q7	1892	1802	1694	1694
q8	2837	2435	2473	2435
q9	7472	7049	7144	7049
q10	2556	2695	2311	2311
q11	561	479	439	439
q12	733	748	643	643
q13	3667	4026	3312	3312
q14	302	317	383	317
q15	557	503	515	503
q16	643	685	611	611
q17	1129	1406	1407	1406
q18	8075	7808	7608	7608
q19	871	839	828	828
q20	1964	2280	1855	1855
q21	4794	4524	4155	4155
q22	1098	1024	979	979
Total cold run time: 51298 ms
Total hot run time: 48248 ms

@doris-robot
Copy link

TPC-DS: Total hot run time: 172711 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 776f4074be5f46cd997bb2179939faab3cee5155, data reload: false

query5	4412	583	455	455
query6	329	223	213	213
query7	4206	473	260	260
query8	325	236	227	227
query9	8740	2630	2652	2630
query10	515	364	316	316
query11	15496	15187	14960	14960
query12	170	115	120	115
query13	1260	458	374	374
query14	6223	2994	2751	2751
query14_1	2665	2631	2664	2631
query15	209	193	176	176
query16	997	488	446	446
query17	1102	676	594	594
query18	2485	442	343	343
query19	223	229	198	198
query20	122	117	113	113
query21	217	136	123	123
query22	3981	4350	4277	4277
query23	16102	15545	15304	15304
query23_1	15456	15458	15265	15265
query24	7469	1553	1163	1163
query24_1	1199	1175	1174	1174
query25	567	501	380	380
query26	1244	256	149	149
query27	2780	444	283	283
query28	4573	2140	2118	2118
query29	760	524	435	435
query30	304	243	211	211
query31	822	624	539	539
query32	77	67	68	67
query33	552	317	282	282
query34	929	900	521	521
query35	714	754	684	684
query36	904	846	805	805
query37	121	84	73	73
query38	2764	2709	2684	2684
query39	779	752	744	744
query39_1	708	724	698	698
query40	215	125	112	112
query41	65	67	61	61
query42	104	99	99	99
query43	471	443	445	443
query44	1301	709	714	709
query45	187	184	172	172
query46	840	944	596	596
query47	1377	1539	1368	1368
query48	304	317	242	242
query49	609	411	323	323
query50	629	276	201	201
query51	3761	3793	3840	3793
query52	105	109	97	97
query53	293	321	279	279
query54	279	254	264	254
query55	78	75	71	71
query56	285	295	291	291
query57	1021	1013	936	936
query58	279	249	244	244
query59	1992	2153	2132	2132
query60	315	302	296	296
query61	163	155	158	155
query62	384	363	311	311
query63	301	272	270	270
query64	4921	1316	986	986
query65	3851	3732	3828	3732
query66	1432	444	299	299
query67	15302	14688	15830	14688
query68	4748	999	710	710
query69	500	349	308	308
query70	1049	903	977	903
query71	371	308	281	281
query72	6153	3674	3554	3554
query73	766	713	309	309
query74	8818	8794	8563	8563
query75	2830	2779	2425	2425
query76	3841	1054	641	641
query77	517	361	283	283
query78	9821	9822	9155	9155
query79	1548	891	580	580
query80	732	549	468	468
query81	512	262	232	232
query82	404	146	105	105
query83	265	251	238	238
query84	251	115	101	101
query85	911	532	454	454
query86	347	317	324	317
query87	2862	2830	2770	2770
query88	3162	2192	2183	2183
query89	380	340	331	331
query90	1960	150	138	138
query91	171	160	141	141
query92	72	67	64	64
query93	1068	926	550	550
query94	646	331	283	283
query95	576	313	354	313
query96	573	456	200	200
query97	2333	2390	2280	2280
query98	228	199	198	198
query99	580	597	537	537
Total cold run time: 251445 ms
Total hot run time: 172711 ms

Copy link
Contributor

@dataroaring dataroaring left a comment

Choose a reason for hiding this comment

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

LGTM

@github-actions
Copy link
Contributor

github-actions bot commented Jan 9, 2026

PR approved by at least one committer and no changes requested.

@github-actions github-actions bot added the approved Indicates a PR has been approved by one committer. label Jan 9, 2026
@dataroaring dataroaring merged commit 6e0a6a0 into apache:master Jan 9, 2026
27 of 28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by one committer. reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants