Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug](column) fix append_data_by_selector_impl reserve too mush useless memory #39581

Merged
merged 3 commits into from
Aug 20, 2024

Conversation

zhangstar333
Copy link
Contributor

@zhangstar333 zhangstar333 commented Aug 19, 2024

Proposed changes

for (auto* place : local_state._value_places) {
                            SCOPED_TIMER(local_state._selector_block_timer);
                            RETURN_IF_ERROR(place->append_block_by_selector(input_block, eos));
}
    for (int i = 0; i < mutable_columns.size(); ++i) {
        columns[i]->append_data_by_selector(mutable_columns[i], _selector);
    }

the columns[I] size is 4096, and _selector size is 1;
so the (4096 - 1) rows is useless;
in a usercase, the block have 4096 rows and 34 columns.
so need bytes is:
1 block * 4096 rows * 4096 reserve * 16 bytes * 34 column * 48 instance = 438086664192 bytes;

it's will cause the query canceled as not have enough memory.

@doris-robot
Copy link

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

Since 2024-03-18, the Document has been moved to doris-website.
See Doris Document.

@zhangstar333 zhangstar333 changed the title [Bug](column) fix append_data_by_selector_impl reserve too mush usele… [Bug](column) fix append_data_by_selector_impl reserve too mush useless memory Aug 19, 2024
@zhangstar333
Copy link
Contributor Author

run buildall


res->reserve(num_rows);
DCHECK_GE(end, begin);
res->reserve(end - begin);
Copy link
Contributor

Choose a reason for hiding this comment

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

add comment here to explain why need using this variable to reserve memory not using num rows

@doris-robot
Copy link

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

------ Round 1 ----------------------------------
q1	18243	4431	4357	4357
q2	2068	210	238	210
q3	11507	1051	1118	1051
q4	10528	794	733	733
q5	7788	2870	2835	2835
q6	267	159	156	156
q7	1058	652	647	647
q8	9374	2094	2125	2094
q9	7406	6604	6575	6575
q10	7041	2268	2245	2245
q11	483	281	263	263
q12	419	246	243	243
q13	18843	3018	3022	3018
q14	292	259	253	253
q15	554	535	520	520
q16	522	405	399	399
q17	1005	648	724	648
q18	7567	6789	6915	6789
q19	6363	1135	1078	1078
q20	718	362	358	358
q21	4191	2930	3010	2930
q22	1128	1070	1018	1018
Total cold run time: 117365 ms
Total hot run time: 38420 ms

----- Round 2, with runtime_filter_mode=off -----
q1	4537	4314	4296	4296
q2	402	301	291	291
q3	2848	2626	2734	2626
q4	1991	1699	1717	1699
q5	5657	5721	5668	5668
q6	234	145	150	145
q7	2168	1795	1723	1723
q8	3283	3532	3477	3477
q9	8828	8720	8768	8720
q10	3543	3358	3281	3281
q11	639	520	520	520
q12	818	644	644	644
q13	17009	3213	3152	3152
q14	316	288	289	288
q15	561	518	513	513
q16	506	454	446	446
q17	1841	1578	1527	1527
q18	8482	7856	7728	7728
q19	6718	1601	1515	1515
q20	2185	1943	1887	1887
q21	13749	5392	5280	5280
q22	1172	1115	1050	1050
Total cold run time: 87487 ms
Total hot run time: 56476 ms

Copy link
Contributor

@yiguolei yiguolei left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

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

@github-actions github-actions bot added approved Indicates a PR has been approved by one committer. reviewed labels Aug 20, 2024
Copy link
Contributor

PR approved by anyone and no changes requested.

@zhangstar333
Copy link
Contributor Author

run buildall

@doris-robot
Copy link

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

------ Round 1 ----------------------------------
q1	18465	4591	4321	4321
q2	2056	206	215	206
q3	10468	1159	1127	1127
q4	10183	791	753	753
q5	7774	2873	2873	2873
q6	265	157	159	157
q7	1024	670	672	670
q8	9376	2113	2098	2098
q9	7064	6590	6599	6590
q10	7110	2295	2211	2211
q11	514	277	276	276
q12	440	263	272	263
q13	17907	2997	3016	2997
q14	312	254	255	254
q15	565	520	534	520
q16	523	406	407	406
q17	1000	712	660	660
q18	7568	6897	6842	6842
q19	5057	1099	1149	1099
q20	729	348	335	335
q21	3903	3021	2879	2879
q22	1144	1050	1036	1036
Total cold run time: 113447 ms
Total hot run time: 38573 ms

----- Round 2, with runtime_filter_mode=off -----
q1	4493	4323	4345	4323
q2	408	312	307	307
q3	2897	2649	2657	2649
q4	1978	1707	1640	1640
q5	5614	5538	5471	5471
q6	239	152	152	152
q7	2117	1704	1696	1696
q8	3257	3434	3357	3357
q9	8469	8441	8477	8441
q10	3453	3204	3190	3190
q11	621	535	528	528
q12	803	650	637	637
q13	17613	3047	3031	3031
q14	333	308	311	308
q15	568	527	528	527
q16	522	442	452	442
q17	1812	1529	1489	1489
q18	7825	7591	7421	7421
q19	5710	1602	1549	1549
q20	2069	1805	1824	1805
q21	13553	5133	5024	5024
q22	1121	1048	1029	1029
Total cold run time: 85475 ms
Total hot run time: 55016 ms

@doris-robot
Copy link

TPC-DS: Total hot run time: 190611 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 8a2e49bebacf5a88bfa2cdc1b7242e769553cf5a, data reload: false

query1	944	393	394	393
query2	6750	1962	1909	1909
query3	6677	232	240	232
query4	27870	23190	23235	23190
query5	4403	709	698	698
query6	308	218	223	218
query7	4621	330	327	327
query8	486	434	426	426
query9	8512	2556	2496	2496
query10	521	344	346	344
query11	16724	15045	15121	15045
query12	199	123	126	123
query13	1696	436	427	427
query14	10251	7323	7238	7238
query15	251	193	187	187
query16	7434	502	525	502
query17	1615	627	579	579
query18	1772	340	336	336
query19	216	167	169	167
query20	142	135	137	135
query21	244	145	143	143
query22	4260	4041	3977	3977
query23	34070	33375	33350	33350
query24	11191	2880	2884	2880
query25	661	421	422	421
query26	976	181	176	176
query27	2645	302	297	297
query28	6909	2158	2129	2129
query29	800	486	436	436
query30	339	198	183	183
query31	1081	842	844	842
query32	122	81	83	81
query33	810	335	334	334
query34	907	516	498	498
query35	949	759	777	759
query36	1107	918	960	918
query37	173	105	105	105
query38	3955	3930	3884	3884
query39	1505	1495	1464	1464
query40	237	155	152	152
query41	138	148	134	134
query42	139	116	119	116
query43	525	499	498	498
query44	1285	781	808	781
query45	220	193	192	192
query46	1119	811	757	757
query47	1926	1809	1833	1809
query48	417	332	324	324
query49	1230	579	570	570
query50	858	466	454	454
query51	6914	6695	6688	6688
query52	124	108	113	108
query53	304	229	221	221
query54	918	506	495	495
query55	89	89	90	89
query56	328	330	348	330
query57	1221	1155	1099	1099
query58	317	307	344	307
query59	2928	2666	2742	2666
query60	350	330	331	330
query61	151	149	151	149
query62	872	699	721	699
query63	255	222	225	222
query64	5556	2391	1857	1857
query65	3300	3205	3202	3202
query66	1298	741	786	741
query67	15557	15148	14881	14881
query68	6034	581	595	581
query69	757	413	321	321
query70	1147	1130	1171	1130
query71	542	313	310	310
query72	7531	2319	2108	2108
query73	825	354	354	354
query74	9199	8882	8752	8752
query75	4949	2759	2759	2759
query76	4197	1047	1033	1033
query77	855	447	428	428
query78	9817	9214	9112	9112
query79	8378	558	553	553
query80	1206	599	608	599
query81	610	259	253	253
query82	1378	154	164	154
query83	388	209	209	209
query84	286	104	104	104
query85	1479	362	348	348
query86	444	310	335	310
query87	4537	4273	4299	4273
query88	4809	2475	2507	2475
query89	579	330	324	324
query90	2093	232	232	232
query91	156	127	129	127
query92	95	111	73	73
query93	6086	575	551	551
query94	1065	309	313	309
query95	388	293	291	291
query96	615	287	280	280
query97	3176	3096	3043	3043
query98	256	230	233	230
query99	1581	1310	1265	1265
Total cold run time: 308130 ms
Total hot run time: 190611 ms

@doris-robot
Copy link

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

query1	0.04	0.05	0.04
query2	0.09	0.04	0.05
query3	0.23	0.05	0.05
query4	1.67	0.08	0.07
query5	0.50	0.49	0.50
query6	1.14	0.73	0.73
query7	0.02	0.01	0.01
query8	0.06	0.05	0.05
query9	0.55	0.50	0.50
query10	0.55	0.55	0.56
query11	0.15	0.12	0.12
query12	0.15	0.13	0.12
query13	0.62	0.60	0.60
query14	0.78	0.80	0.80
query15	0.86	0.83	0.83
query16	0.38	0.38	0.36
query17	1.05	0.99	1.05
query18	0.21	0.21	0.21
query19	1.82	1.83	1.68
query20	0.01	0.01	0.02
query21	15.40	0.68	0.68
query22	3.97	7.37	2.14
query23	18.29	1.40	1.34
query24	2.12	0.22	0.25
query25	0.16	0.09	0.08
query26	0.27	0.18	0.18
query27	0.09	0.09	0.08
query28	13.24	1.04	1.02
query29	12.66	3.35	3.29
query30	0.44	0.25	0.24
query31	2.81	0.42	0.41
query32	3.23	0.49	0.48
query33	2.96	2.97	2.96
query34	17.02	4.42	4.31
query35	4.38	4.44	4.41
query36	0.68	0.47	0.49
query37	0.21	0.18	0.17
query38	0.18	0.16	0.17
query39	0.06	0.05	0.05
query40	0.16	0.14	0.14
query41	0.11	0.07	0.06
query42	0.07	0.07	0.06
query43	0.06	0.07	0.05
Total cold run time: 109.45 s
Total hot run time: 31.25 s

Copy link
Contributor

@zclllyybb zclllyybb left a comment

Choose a reason for hiding this comment

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

LGTM

@yiguolei yiguolei merged commit cfcd60c into apache:master Aug 20, 2024
27 of 31 checks passed
zhangstar333 added a commit to zhangstar333/incubator-doris that referenced this pull request Aug 20, 2024
…ss memory (apache#39581)

## Proposed changes

```
for (auto* place : local_state._value_places) {
                            SCOPED_TIMER(local_state._selector_block_timer);
                            RETURN_IF_ERROR(place->append_block_by_selector(input_block, eos));
}
    for (int i = 0; i < mutable_columns.size(); ++i) {
        columns[i]->append_data_by_selector(mutable_columns[i], _selector);
    }
```
the columns[I] size is 4096, and _selector size is 1;
so the (4096 - 1) rows is useless;
in a usercase, the block have 4096 rows and 34 columns.
so need bytes is:
1 block * 4096 rows * 4096 reserve * 16 bytes * 34 column * 48 instance
= 438086664192 bytes;

it's will cause the query canceled as not have enough memory.
yiguolei pushed a commit that referenced this pull request Aug 21, 2024
… mush useless memory (#39581) (#39635)

## Proposed changes

cherry-pick from master #39581
dataroaring pushed a commit that referenced this pull request Aug 26, 2024
…ss memory (#39581)

## Proposed changes

```
for (auto* place : local_state._value_places) {
                            SCOPED_TIMER(local_state._selector_block_timer);
                            RETURN_IF_ERROR(place->append_block_by_selector(input_block, eos));
}
    for (int i = 0; i < mutable_columns.size(); ++i) {
        columns[i]->append_data_by_selector(mutable_columns[i], _selector);
    }
```
the columns[I] size is 4096, and _selector size is 1;
so the (4096 - 1) rows is useless;
in a usercase, the block have 4096 rows and 34 columns.
so need bytes is:
1 block * 4096 rows * 4096 reserve * 16 bytes * 34 column * 48 instance
= 438086664192 bytes;

it's will cause the query canceled as not have enough memory.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants