Skip to content

Conversation

@yiguolei
Copy link
Contributor

@yiguolei yiguolei commented Sep 9, 2025

picked from #55796

PipelineTask is also hold by task queue(
apache#49753), so that it maybe the last
one to be destructed. But pipeline task hold some objects, like
operators, shared state, etc. So that should release memory manually.

F20250908 20:07:41.329619 39575 mem_tracker_limiter.cpp:112] mem tracker
label: Query#Id=ec8535b35ed34f54-afd752d5d1dd97c1, consumption: 16640,
peak consumption: 16640, mem tracker not equal to 0 when mem
tracker destruct, this usually means that memory tracking is inaccurate
and SCOPED_ATTACH_TASK and SCOPED_SWITCH_THREAD_MEM_TRACKER_LIMITER are
not used correctly. If the log is truncated, search for `Address
Sanitizer` in the be.INFO log to see more information.1. For query and
load, memory leaks may have occurred, it is expected that the query mem
tracker will be bound to the thread context using SCOPED_ATTACH_TASK and
SCOPED_SWITCH_THREAD_MEM_TRACKER_LIMITER before all memory alloc and
free. 2. If a memory alloc is recorded by this tracker, it is expected
that be recorded in this tracker when memory is freed. 3. Merge the
remaining memory tracking value by this tracker into Orphan, if you
observe that Orphan is not equal to 0 in the mem tracker web or log,
this indicates that there may be a memory leak. 4. If you need to
transfer memory tracking value between two trackers, can use
transfer_to..[Address Sanitizer]:
 memory not be freed:
[Address Sanitizer] buf not be freed, mem tracker label:
Query#Id=ec8535b35ed34f54-afd752d5d1dd97c1, consumption: 16640, peak
consumption: 16640, buf: 0x7d87c8761d00, size 4096, strack trace:
0# doris::Allocator<false, false, false, doris::DefaultMemoryAllocator,
false>::alloc(unsigned long, unsigned long)
1# void doris::vectorized::PODArrayBase<1ul, 4096ul,
doris::Allocator<false, false, false, doris::DefaultMemoryAllocator,
false>, 16ul, 15ul>::alloc<>(unsigned long)
2# void doris::vectorized::PODArray<signed char, 4096ul,
doris::Allocator<false, false, false, doris::DefaultMemoryAllocator,
false>, 16ul, 15ul>::push_back<long>(long&&)
3#
doris::vectorized::ColumnVector<(doris::PrimitiveType)3>::insert(doris::vectorized::Field
const&)
4# doris::vectorized::IDataType::create_column_const(unsigned long,
doris::vectorized::Field const&) const
        5#  doris::vectorized::VLiteral::init(doris::TExprNode const&)
6# doris::vectorized::VLiteral::VLiteral(doris::TExprNode const&, bool)
7#
std::__shared_count<(__gnu_cxx::_Lock_policy)2>::__shared_count<doris::vectorized::VLiteral,
std::allocator<void>, doris::TExprNode
const&>(doris::vectorized::VLiteral*&,
std::_Sp_alloc_shared_tag<std::allocator<void> >, doris::TExprNode
const&)
8# doris::vectorized::VExpr::create_expr(doris::TExprNode const&,
std::shared_ptr<doris::vectorized::VExpr>&)
9#
doris::vectorized::VExpr::create_tree_from_thrift(std::vector<doris::TExprNode,
std::allocator<doris::TExprNode> > const&, int*,
std::shared_ptr<doris::vectorized::VExpr>&,
std::shared_ptr<doris::vectorized::VExprContext>&)
10# doris::vectorized::VExpr::create_expr_tree(doris::TExpr const&,
std::shared_ptr<doris::vectorized::VExprContext>&)
11# doris::pipeline::OperatorXBase::init(doris::TPlanNode const&,
doris::RuntimeState*)
12#
doris::pipeline::ScanOperatorX<doris::pipeline::OlapScanLocalState>::init(doris::TPlanNode
const&, doris::RuntimeState*)
13#
doris::pipeline::PipelineFragmentContext::_create_tree_helper(doris::ObjectPool*,
std::vector<doris::TPlanNode, std::allocator<doris::TPlanNode> > const&,
doris::TPipelineFragmentParams const&, doris::DescriptorTbl const&,
std::shared_ptr<doris::pipeline::OperatorXBase>, int*,
std::shared_ptr<doris::pipeline::OperatorXBase>*,
std::shared_ptr<doris::pipeline::Pipeline>&, int, bool)
14#
doris::pipeline::PipelineFragmentContext::_build_pipelines(doris::ObjectPool*,
doris::TPipelineFragmentParams const&, doris::DescriptorTbl const&,
std::shared_ptr<doris::pipeline::OperatorXBase>*,
std::shared_ptr<doris::pipeline::Pipeline>)
15#
doris::pipeline::PipelineFragmentContext::prepare(doris::TPipelineFragmentParams
const&, doris::ThreadPool*)
16#
doris::FragmentMgr::exec_plan_fragment(doris::TPipelineFragmentParams
const&, doris::QuerySource, std::function<void (doris::RuntimeState*,
doris::Status*)> const&, doris::TPipelineFragmentParamsList const&)
17#
doris::FragmentMgr::exec_plan_fragment(doris::TPipelineFragmentParams
const&, doris::QuerySource, doris::TPipelineFragmentParamsList const&)
18#
doris::PInternalService::_exec_plan_fragment_impl(std::__cxx11::basic_string<char,
std::char_traits<char>, std::allocator<char> > const&,
doris::PFragmentRequestVersion, bool, std::function<void
(doris::RuntimeState*, doris::Status*)> const&)
19#
doris::PInternalService::_exec_plan_fragment_in_pthread(google::protobuf::RpcController*,
doris::PExecPlanFragmentRequest const*, doris::PExecPlanFragmentResult*,
google::protobuf::Closure*)
        20# doris::WorkThreadPool<false>::work_thread(int)
        21# execute_native_thread_routine
        22# asan_thread_start(void*)
        23# ?
@yiguolei yiguolei requested a review from morrySnow as a code owner September 9, 2025 11:05
@Thearas
Copy link
Contributor

Thearas commented Sep 9, 2025

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?

@yiguolei
Copy link
Contributor Author

yiguolei commented Sep 9, 2025

run buildall

@yiguolei
Copy link
Contributor Author

run buildall

@doris-robot
Copy link

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

------ Round 1 ----------------------------------
q1	17584	5440	5447	5440
q2	2020	397	282	282
q3	12349	1233	750	750
q4	10299	887	456	456
q5	9403	2362	2154	2154
q6	183	163	132	132
q7	873	743	628	628
q8	9338	1420	1120	1120
q9	5279	4995	4796	4796
q10	6771	2280	1830	1830
q11	475	281	260	260
q12	337	349	225	225
q13	17773	3620	2978	2978
q14	229	226	211	211
q15	539	473	458	458
q16	414	418	370	370
q17	605	853	365	365
q18	6964	6426	6353	6353
q19	1214	961	532	532
q20	341	355	210	210
q21	2854	2126	1973	1973
q22	1068	1052	990	990
Total cold run time: 106912 ms
Total hot run time: 32513 ms

----- Round 2, with runtime_filter_mode=off -----
q1	5462	5448	5450	5448
q2	233	323	238	238
q3	2202	2668	2333	2333
q4	1370	1799	1460	1460
q5	4450	5000	4930	4930
q6	167	160	134	134
q7	2037	1930	1823	1823
q8	2641	2765	2667	2667
q9	7315	7262	7187	7187
q10	3019	3299	2657	2657
q11	579	506	487	487
q12	627	781	601	601
q13	3438	3800	3159	3159
q14	295	311	263	263
q15	530	490	471	471
q16	436	484	416	416
q17	1220	1708	1248	1248
q18	7581	7365	7335	7335
q19	784	1158	1021	1021
q20	2018	2037	1900	1900
q21	5297	4847	4630	4630
q22	1089	1053	1041	1041
Total cold run time: 52790 ms
Total hot run time: 51449 ms

@hello-stephen
Copy link
Contributor

BE UT Coverage Report

Increment line coverage 0.00% (0/10) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 45.54% (12757/28011)
Line Coverage 36.37% (113726/312698)
Region Coverage 34.00% (65053/191312)
Branch Coverage 31.04% (34143/110012)

@doris-robot
Copy link

TPC-DS: Total hot run time: 192348 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 7209b80392541ec272ac48dec044beffccad99cd, data reload: false

query1	944	416	391	391
query2	6227	1969	1910	1910
query3	8682	201	194	194
query4	33694	24214	23393	23393
query5	4434	609	460	460
query6	300	203	186	186
query7	4229	489	314	314
query8	311	263	247	247
query9	9393	2628	2609	2609
query10	502	340	260	260
query11	17952	15453	15233	15233
query12	163	106	104	104
query13	1557	543	410	410
query14	9458	6590	6660	6590
query15	259	197	185	185
query16	8076	666	519	519
query17	1571	750	606	606
query18	2128	431	320	320
query19	203	199	177	177
query20	126	124	121	121
query21	204	131	110	110
query22	4607	4458	4468	4458
query23	34822	34268	34227	34227
query24	8605	2686	2690	2686
query25	525	493	405	405
query26	733	282	164	164
query27	2595	478	361	361
query28	5484	2238	2176	2176
query29	673	560	450	450
query30	239	184	162	162
query31	1000	898	839	839
query32	87	58	57	57
query33	486	376	317	317
query34	727	841	529	529
query35	794	822	751	751
query36	1044	1062	956	956
query37	102	90	74	74
query38	3981	4037	3991	3991
query39	1523	1488	1487	1487
query40	204	132	116	116
query41	58	56	47	47
query42	123	107	110	107
query43	531	513	488	488
query44	1336	823	839	823
query45	217	177	168	168
query46	892	1078	682	682
query47	1972	1983	1967	1967
query48	414	440	364	364
query49	723	484	393	393
query50	681	687	441	441
query51	7210	7326	7312	7312
query52	107	100	93	93
query53	228	268	193	193
query54	553	540	488	488
query55	84	81	84	81
query56	261	268	276	268
query57	1252	1254	1221	1221
query58	247	224	223	223
query59	3047	3103	3019	3019
query60	299	303	289	289
query61	142	139	132	132
query62	785	758	689	689
query63	230	195	205	195
query64	3727	1100	750	750
query65	3376	3280	3301	3280
query66	871	437	333	333
query67	16191	15995	15455	15455
query68	7385	825	543	543
query69	513	310	318	310
query70	1176	1131	1136	1131
query71	379	290	264	264
query72	5303	3738	3802	3738
query73	633	748	357	357
query74	10153	9150	9165	9150
query75	3204	3130	2664	2664
query76	2978	1179	770	770
query77	532	375	282	282
query78	10304	10291	9601	9601
query79	3283	891	604	604
query80	826	528	435	435
query81	503	265	220	220
query82	385	121	90	90
query83	169	159	145	145
query84	288	97	84	84
query85	782	362	295	295
query86	388	295	273	273
query87	4349	4321	4295	4295
query88	4846	2431	2395	2395
query89	398	340	295	295
query90	1777	187	187	187
query91	137	154	108	108
query92	67	58	50	50
query93	2384	888	541	541
query94	685	408	316	316
query95	340	285	271	271
query96	481	604	279	279
query97	3175	3240	3135	3135
query98	245	213	198	198
query99	1575	1395	1276	1276
Total cold run time: 293844 ms
Total hot run time: 192348 ms

@doris-robot
Copy link

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

query1	0.03	0.04	0.03
query2	0.06	0.03	0.03
query3	0.24	0.07	0.06
query4	1.62	0.11	0.10
query5	0.53	0.51	0.52
query6	1.13	0.73	0.72
query7	0.03	0.02	0.02
query8	0.05	0.03	0.03
query9	0.56	0.50	0.50
query10	0.55	0.55	0.58
query11	0.14	0.10	0.10
query12	0.13	0.11	0.11
query13	0.62	0.61	0.58
query14	0.78	0.80	0.79
query15	0.84	0.85	0.82
query16	0.38	0.38	0.38
query17	1.03	0.99	1.06
query18	0.25	0.23	0.22
query19	1.97	1.85	1.78
query20	0.01	0.01	0.01
query21	15.41	0.89	0.55
query22	0.74	0.79	0.59
query23	15.19	1.50	0.55
query24	3.08	1.24	1.51
query25	0.12	0.07	0.12
query26	0.33	0.17	0.14
query27	0.05	0.05	0.05
query28	13.90	1.03	0.45
query29	12.59	3.93	3.22
query30	0.26	0.09	0.07
query31	2.82	0.62	0.37
query32	3.23	0.52	0.46
query33	3.00	3.02	3.07
query34	16.44	5.13	4.53
query35	4.50	4.58	4.56
query36	0.66	0.50	0.48
query37	0.08	0.06	0.06
query38	0.04	0.03	0.04
query39	0.03	0.03	0.02
query40	0.17	0.14	0.13
query41	0.08	0.03	0.02
query42	0.04	0.02	0.02
query43	0.04	0.03	0.02
Total cold run time: 103.75 s
Total hot run time: 28.98 s

@morrySnow morrySnow changed the title [branch-3.1](memtracker) memory not consumed by memtracker (#55796) branch-3.1: (memtracker) memory not consumed by memtracker #55796 Sep 11, 2025
@morrySnow morrySnow merged commit c58b3e9 into apache:branch-3.1 Sep 11, 2025
20 of 23 checks passed
@morrySnow morrySnow mentioned this pull request Sep 22, 2025
yiguolei added a commit to yiguolei/incubator-doris that referenced this pull request Sep 28, 2025
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.

5 participants