Skip to content

Conversation

@eldenmoon
Copy link
Member

@eldenmoon eldenmoon commented Nov 28, 2025

  • Replace the per-row seek + next_batch(1) loop in MapFileColumnIterator::read_by_rowids with batched offset reads via OffsetFileColumnIterator::read_by_rowids to derive key/value ranges for the requested rowids.
  • Compute per-row map sizes from offset[rowid] and offset[rowid+1], using the page-tail next_array_item_ordinal sentinel for the last row when rowid+1 is out of bounds.
  • Skip key/value decoding for null rows by consulting a pre-fetched null map, and add a safety check to reject non-nullable destination columns when the underlying map reader is nullable.
  • Reuse a small peek column in OffsetFileColumnIterator::_peek_one_offset to avoid repeated temporary column allocations when reading page sentinels.
  • Add a unit test (MapReadByRowidsSkipReadingResizesDestination) to verify that read_by_rowids honors the SKIP_READING flag and only resizes the destination column without touching sub-iterators.
  • Improve performance from ~19s to ~0.1s in the worst-case access pattern, and
    from ~6s to ~3s in the normal case.

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

@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?

@eldenmoon
Copy link
Member Author

run buildall

@doris-robot
Copy link

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

------ Round 1 ----------------------------------
q1	17670	5072	4943	4943
q2	2004	319	211	211
q3	10296	1282	736	736
q4	10230	947	366	366
q5	7519	2534	2210	2210
q6	186	172	144	144
q7	947	785	661	661
q8	9353	1373	1026	1026
q9	7079	5273	5350	5273
q10	6898	2242	1824	1824
q11	509	312	296	296
q12	378	381	224	224
q13	17789	3655	3032	3032
q14	233	244	213	213
q15	581	522	516	516
q16	1032	1012	967	967
q17	594	792	468	468
q18	7376	7249	7069	7069
q19	1082	958	587	587
q20	336	358	231	231
q21	3559	3501	2424	2424
q22	1025	979	958	958
Total cold run time: 106676 ms
Total hot run time: 34379 ms

----- Round 2, with runtime_filter_mode=off -----
q1	4971	4951	4912	4912
q2	336	401	317	317
q3	2114	2709	2304	2304
q4	1294	1806	1355	1355
q5	4230	4424	4537	4424
q6	222	181	138	138
q7	2121	1936	1823	1823
q8	2603	2549	2493	2493
q9	7633	7401	7549	7401
q10	3089	3262	2855	2855
q11	573	518	499	499
q12	710	792	656	656
q13	3583	4008	3380	3380
q14	320	314	275	275
q15	580	513	505	505
q16	1101	1118	1090	1090
q17	1208	1449	1394	1394
q18	7878	7680	7417	7417
q19	800	744	747	744
q20	1909	1951	1854	1854
q21	4578	4276	4199	4199
q22	1110	1073	990	990
Total cold run time: 52963 ms
Total hot run time: 51025 ms

@doris-robot
Copy link

TPC-DS: Total hot run time: 184924 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 3b9e3230252c11526c88e632a4a0d0d9a22f2dbe, data reload: false

query1	1073	402	409	402
query2	6568	1543	1592	1543
query3	6773	224	222	222
query4	25066	22919	23040	22919
query5	4864	625	452	452
query6	341	237	220	220
query7	4648	520	305	305
query8	301	259	261	259
query9	8732	2599	2585	2585
query10	543	355	312	312
query11	15259	14978	14886	14886
query12	185	123	119	119
query13	1698	569	451	451
query14	11066	8886	8893	8886
query15	215	212	188	188
query16	7563	709	527	527
query17	1216	779	651	651
query18	2033	438	343	343
query19	213	212	203	203
query20	137	125	126	125
query21	220	148	120	120
query22	3891	4190	3845	3845
query23	32885	31896	31988	31896
query24	8478	2426	2404	2404
query25	631	553	488	488
query26	1256	277	177	177
query27	2717	502	367	367
query28	4320	2172	2157	2157
query29	847	658	516	516
query30	315	241	218	218
query31	828	723	649	649
query32	90	79	79	79
query33	617	390	349	349
query34	805	869	608	608
query35	819	825	745	745
query36	901	933	838	838
query37	128	120	90	90
query38	3313	3331	3315	3315
query39	1477	1406	1404	1404
query40	223	132	118	118
query41	65	62	62	62
query42	123	114	117	114
query43	459	459	424	424
query44	1272	766	754	754
query45	200	196	189	189
query46	875	993	652	652
query47	1692	1688	1658	1658
query48	400	426	322	322
query49	774	500	416	416
query50	665	696	415	415
query51	3834	3977	4083	3977
query52	123	112	108	108
query53	232	272	200	200
query54	309	320	286	286
query55	97	94	92	92
query56	334	340	321	321
query57	1132	1159	1110	1110
query58	293	268	282	268
query59	2427	2473	2308	2308
query60	356	399	344	344
query61	180	159	157	157
query62	785	713	652	652
query63	234	196	197	196
query64	4470	1180	884	884
query65	4058	3993	3984	3984
query66	1137	439	354	354
query67	15290	14962	14825	14825
query68	8442	963	626	626
query69	515	342	312	312
query70	1316	1261	1127	1127
query71	476	338	321	321
query72	5766	4865	4854	4854
query73	704	575	361	361
query74	8774	8761	8673	8673
query75	4010	3307	2795	2795
query76	3794	1116	705	705
query77	835	399	311	311
query78	9445	9601	8769	8769
query79	2261	818	589	589
query80	621	561	493	493
query81	485	269	233	233
query82	462	160	133	133
query83	303	273	251	251
query84	307	111	100	100
query85	946	478	448	448
query86	394	318	284	284
query87	3533	3500	3420	3420
query88	3861	2275	2274	2274
query89	388	329	290	290
query90	1870	216	208	208
query91	181	170	147	147
query92	80	71	65	65
query93	1763	982	677	677
query94	738	455	346	346
query95	505	424	403	403
query96	505	545	283	283
query97	2893	2985	2885	2885
query98	244	225	211	211
query99	1376	1421	1277	1277
Total cold run time: 272864 ms
Total hot run time: 184924 ms

…tched map access

- Replace the per-row seek + next_batch(1) loop in MapFileColumnIterator::read_by_rowids
  with batched offset reads via OffsetFileColumnIterator::read_by_rowids to derive
  key/value ranges for the requested rowids.
- Compute per-row map sizes from offset[rowid] and offset[rowid+1], using the
  page-tail next_array_item_ordinal sentinel for the last row when rowid+1 is
  out of bounds.
- Skip key/value decoding for null rows by consulting a pre-fetched null map,
  and add a safety check to reject non-nullable destination columns when the
  underlying map reader is nullable.
- Reuse a small peek column in OffsetFileColumnIterator::_peek_one_offset to
  avoid repeated temporary column allocations when reading page sentinels.
- Add a unit test (MapReadByRowidsSkipReadingResizesDestination) to verify that
  read_by_rowids honors the SKIP_READING flag and only resizes the destination
  column without touching sub-iterators.
@eldenmoon
Copy link
Member Author

run buildall

@doris-robot
Copy link

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

query1	0.05	0.05	0.05
query2	0.09	0.05	0.06
query3	0.26	0.09	0.11
query4	1.63	0.11	0.12
query5	0.27	0.27	0.25
query6	1.16	0.65	0.63
query7	0.03	0.03	0.02
query8	0.05	0.04	0.05
query9	0.59	0.50	0.50
query10	0.54	0.54	0.57
query11	0.15	0.12	0.10
query12	0.15	0.12	0.11
query13	0.63	0.60	0.61
query14	0.99	1.00	0.98
query15	0.82	0.81	0.82
query16	0.39	0.39	0.42
query17	1.00	1.05	1.00
query18	0.24	0.24	0.21
query19	1.96	1.83	1.75
query20	0.02	0.01	0.01
query21	15.45	0.29	0.13
query22	4.93	0.05	0.04
query23	15.98	0.26	0.11
query24	1.50	0.37	0.17
query25	0.08	0.06	0.08
query26	0.16	0.14	0.13
query27	0.08	0.04	0.04
query28	3.92	1.23	1.02
query29	12.61	4.00	3.25
query30	0.28	0.13	0.12
query31	2.82	0.61	0.41
query32	3.25	0.54	0.46
query33	3.11	3.03	3.04
query34	16.47	5.24	4.53
query35	4.56	4.56	4.59
query36	0.68	0.50	0.49
query37	0.11	0.07	0.06
query38	0.07	0.04	0.04
query39	0.04	0.04	0.03
query40	0.17	0.14	0.15
query41	0.08	0.04	0.03
query42	0.04	0.02	0.02
query43	0.05	0.04	0.03
Total cold run time: 97.46 s
Total hot run time: 27.14 s

@doris-robot
Copy link

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

------ Round 1 ----------------------------------
q1	17594	5123	4887	4887
q2	2054	313	212	212
q3	10263	1319	741	741
q4	10227	884	364	364
q5	7461	2460	2224	2224
q6	199	174	136	136
q7	932	800	633	633
q8	9367	1427	1035	1035
q9	7464	5236	5320	5236
q10	6908	2219	1814	1814
q11	519	311	301	301
q12	385	371	238	238
q13	17774	3704	3029	3029
q14	233	236	229	229
q15	581	517	519	517
q16	906	859	807	807
q17	604	781	481	481
q18	7435	7221	7088	7088
q19	1103	951	572	572
q20	345	334	229	229
q21	3932	3569	2549	2549
q22	1046	993	937	937
Total cold run time: 107332 ms
Total hot run time: 34259 ms

----- Round 2, with runtime_filter_mode=off -----
q1	5146	4948	4916	4916
q2	348	391	324	324
q3	2127	2652	2366	2366
q4	1328	1736	1274	1274
q5	4246	4107	4174	4107
q6	208	169	128	128
q7	1887	1820	1698	1698
q8	2515	2438	2350	2350
q9	6999	6969	6899	6899
q10	2929	3086	2660	2660
q11	591	505	491	491
q12	634	716	577	577
q13	3240	3631	3006	3006
q14	278	294	273	273
q15	558	517	511	511
q16	899	894	846	846
q17	1098	1336	1330	1330
q18	7273	7094	7029	7029
q19	796	784	760	760
q20	1921	1975	1814	1814
q21	4657	4320	4243	4243
q22	1063	1056	970	970
Total cold run time: 50741 ms
Total hot run time: 48572 ms

@doris-robot
Copy link

TPC-DS: Total hot run time: 182291 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 a9b5d9dcafb5d24feef81c1c42a8e82829d8d0ff, data reload: false

query1	1054	410	392	392
query2	6608	1607	1596	1596
query3	6752	229	225	225
query4	25609	23389	22780	22780
query5	4422	638	462	462
query6	359	240	219	219
query7	4649	520	314	314
query8	312	259	243	243
query9	8697	2607	2585	2585
query10	522	345	304	304
query11	15383	15185	14897	14897
query12	174	123	113	113
query13	1669	587	472	472
query14	9099	5603	5566	5566
query15	210	202	183	183
query16	7293	708	536	536
query17	1256	796	639	639
query18	2008	445	357	357
query19	214	206	195	195
query20	131	126	122	122
query21	216	144	119	119
query22	3971	4046	3953	3953
query23	33013	31929	32107	31929
query24	8490	2431	2360	2360
query25	644	556	507	507
query26	1252	284	167	167
query27	2733	537	380	380
query28	4353	2165	2155	2155
query29	874	664	552	552
query30	320	245	212	212
query31	824	736	723	723
query32	92	81	76	76
query33	610	420	351	351
query34	834	871	540	540
query35	809	911	740	740
query36	879	936	838	838
query37	128	107	87	87
query38	3802	4127	3921	3921
query39	1461	1468	1519	1468
query40	232	150	131	131
query41	68	65	61	61
query42	139	129	128	128
query43	458	462	431	431
query44	1309	788	782	782
query45	197	189	191	189
query46	911	1034	661	661
query47	1825	1738	1641	1641
query48	397	440	331	331
query49	812	492	394	394
query50	664	713	418	418
query51	3914	4026	3869	3869
query52	115	115	107	107
query53	237	265	201	201
query54	315	300	278	278
query55	100	92	90	90
query56	359	346	323	323
query57	1146	1173	1084	1084
query58	284	288	269	269
query59	2392	2416	2406	2406
query60	356	357	374	357
query61	160	157	166	157
query62	819	707	652	652
query63	228	197	202	197
query64	4609	1204	883	883
query65	4051	3993	3974	3974
query66	1173	444	343	343
query67	15581	15026	14778	14778
query68	8344	975	656	656
query69	528	348	305	305
query70	1128	1049	1004	1004
query71	490	341	329	329
query72	5870	5000	5000	5000
query73	751	634	365	365
query74	8861	8768	8603	8603
query75	3639	3073	2587	2587
query76	3676	1108	714	714
query77	809	410	317	317
query78	9449	9723	8734	8734
query79	2003	837	572	572
query80	661	595	494	494
query81	512	268	246	246
query82	215	144	111	111
query83	274	269	246	246
query84	262	114	101	101
query85	899	489	449	449
query86	382	293	276	276
query87	4042	4096	4028	4028
query88	3465	2264	2264	2264
query89	378	342	302	302
query90	1961	222	218	218
query91	171	168	142	142
query92	83	70	67	67
query93	2285	988	671	671
query94	668	429	332	332
query95	501	420	405	405
query96	504	545	285	285
query97	2619	2740	2573	2573
query98	247	222	212	212
query99	1302	1378	1270	1270
Total cold run time: 271556 ms
Total hot run time: 182291 ms

@doris-robot
Copy link

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

query1	0.05	0.04	0.05
query2	0.10	0.05	0.04
query3	0.26	0.09	0.08
query4	1.61	0.12	0.11
query5	0.26	0.25	0.26
query6	1.19	0.65	0.64
query7	0.03	0.02	0.02
query8	0.05	0.04	0.04
query9	0.59	0.51	0.49
query10	0.56	0.56	0.55
query11	0.15	0.11	0.11
query12	0.14	0.11	0.12
query13	0.62	0.60	0.60
query14	0.98	0.98	1.00
query15	0.83	0.80	0.79
query16	0.40	0.37	0.40
query17	1.05	0.99	1.00
query18	0.23	0.22	0.22
query19	1.92	1.82	1.89
query20	0.01	0.01	0.02
query21	15.45	0.27	0.14
query22	4.87	0.05	0.05
query23	16.10	0.26	0.10
query24	1.05	0.55	0.24
query25	0.10	0.06	0.09
query26	0.14	0.14	0.14
query27	0.06	0.06	0.05
query28	3.19	1.21	1.02
query29	12.58	3.95	3.19
query30	0.27	0.14	0.11
query31	2.84	0.60	0.41
query32	3.24	0.55	0.46
query33	3.06	3.17	3.09
query34	16.98	5.21	4.54
query35	4.55	4.57	4.61
query36	0.68	0.49	0.49
query37	0.10	0.06	0.06
query38	0.06	0.04	0.04
query39	0.04	0.03	0.03
query40	0.17	0.15	0.13
query41	0.09	0.03	0.03
query42	0.04	0.02	0.02
query43	0.05	0.04	0.04
Total cold run time: 96.74 s
Total hot run time: 27.27 s

@hello-stephen
Copy link
Contributor

BE UT Coverage Report

Increment line coverage 76.34% (71/93) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 52.89% (18506/34988)
Line Coverage 38.43% (169538/441181)
Region Coverage 33.24% (131639/396077)
Branch Coverage 34.18% (56685/165837)

@hello-stephen
Copy link
Contributor

BE Regression && UT Coverage Report

Increment line coverage 94.62% (88/93) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 71.68% (24589/34306)
Line Coverage 58.25% (256768/440787)
Region Coverage 53.48% (214389/400887)
Branch Coverage 54.89% (91527/166732)

@hello-stephen
Copy link
Contributor

BE Regression && UT Coverage Report

Increment line coverage 94.62% (88/93) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 71.68% (24590/34306)
Line Coverage 58.26% (256784/440787)
Region Coverage 53.47% (214357/400887)
Branch Coverage 54.90% (91535/166732)

Copy link
Contributor

@csun5285 csun5285 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 Dec 1, 2025

PR approved by anyone and no changes requested.

Copy link
Member

@airborne12 airborne12 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 github-actions bot added the approved Indicates a PR has been approved by one committer. label Dec 3, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Dec 3, 2025

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

@eldenmoon eldenmoon merged commit e13bcdd into apache:master Dec 3, 2025
30 of 34 checks passed
nagisa-kunhah pushed a commit to nagisa-kunhah/doris that referenced this pull request Dec 14, 2025
…tched map access (apache#58485)

- Replace the per-row seek + next_batch(1) loop in
MapFileColumnIterator::read_by_rowids with batched offset reads via
OffsetFileColumnIterator::read_by_rowids to derive key/value ranges for
the requested rowids.
- Compute per-row map sizes from offset[rowid] and offset[rowid+1],
using the page-tail next_array_item_ordinal sentinel for the last row
when rowid+1 is out of bounds.
- Skip key/value decoding for null rows by consulting a pre-fetched null
map, and add a safety check to reject non-nullable destination columns
when the underlying map reader is nullable.
- Reuse a small peek column in
OffsetFileColumnIterator::_peek_one_offset to avoid repeated temporary
column allocations when reading page sentinels.
- Add a unit test (MapReadByRowidsSkipReadingResizesDestination) to
verify that read_by_rowids honors the SKIP_READING flag and only resizes
the destination column without touching sub-iterators.
- Improve performance from ~19s to ~0.1s in the worst-case access
pattern, and
  from ~6s to ~3s in the normal case.
mrhhsg pushed a commit that referenced this pull request Dec 23, 2025
…tched map access (#58485)

- Replace the per-row seek + next_batch(1) loop in
MapFileColumnIterator::read_by_rowids with batched offset reads via
OffsetFileColumnIterator::read_by_rowids to derive key/value ranges for
the requested rowids.
- Compute per-row map sizes from offset[rowid] and offset[rowid+1],
using the page-tail next_array_item_ordinal sentinel for the last row
when rowid+1 is out of bounds.
- Skip key/value decoding for null rows by consulting a pre-fetched null
map, and add a safety check to reject non-nullable destination columns
when the underlying map reader is nullable.
- Reuse a small peek column in
OffsetFileColumnIterator::_peek_one_offset to avoid repeated temporary
column allocations when reading page sentinels.
- Add a unit test (MapReadByRowidsSkipReadingResizesDestination) to
verify that read_by_rowids honors the SKIP_READING flag and only resizes
the destination column without touching sub-iterators.
- Improve performance from ~19s to ~0.1s in the worst-case access
pattern, and
  from ~6s to ~3s in the normal case.
yiguolei pushed a commit that referenced this pull request Dec 24, 2025
…rning (#59286)

### What problem does this PR solve?

Problem Summary:

### Release note

Cherry-pick #58370 #58354 #59043 #58851 #58485 #58682 #58614 #58373
#57204 #58719 #58471 #58573 #58657

### Check List (For Author)

- Test <!-- At least one of them must be included. -->
    - [ ] 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 <!-- Add your reason?  -->

- Behavior changed:
    - [ ] No.
    - [ ] Yes. <!-- Explain the behavior change -->

- Does this need documentation?
    - [ ] No.
- [ ] Yes. <!-- Add document PR link here. eg:
apache/doris-website#1214 -->

### Check List (For Reviewer who merge this PR)

- [ ] Confirm the release note
- [ ] Confirm test cases
- [ ] Confirm document
- [ ] Add branch pick label <!-- Add branch pick label that this PR
should merge into -->

---------

Co-authored-by: 924060929 <lanhuajian@selectdb.com>
Co-authored-by: Jerry Hu <mrhhsg@gmail.com>
Co-authored-by: Jerry Hu <hushenggang@selectdb.com>
Co-authored-by: lihangyu <lihangyu@selectdb.com>
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. dev/4.0.3-merged reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants