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

[opt](udf-cache) cache more udf classes #40404

Merged
merged 5 commits into from
Sep 25, 2024
Merged

Conversation

morningman
Copy link
Contributor

@morningman morningman commented Sep 5, 2024

In this PR #34980, we cache the class load of java udf.
But when calling init() method, it is still very time consuming
when calling Class.forName().

This PR add a new class UdfClassCache to cache more things
so that the init() method will not cost too much time.

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

@morningman
Copy link
Contributor Author

run buildall

@morningman morningman marked this pull request as ready for review September 5, 2024 16:15
@doris-robot
Copy link

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

------ Round 1 ----------------------------------
q1	18005	4492	4401	4401
q2	2563	191	181	181
q3	12244	1088	1121	1088
q4	10588	776	770	770
q5	7875	2849	2812	2812
q6	233	139	137	137
q7	1069	634	590	590
q8	9322	2042	2072	2042
q9	7186	6512	6569	6512
q10	7015	2188	2210	2188
q11	481	250	247	247
q12	398	224	224	224
q13	17831	3083	3081	3081
q14	294	236	252	236
q15	531	485	472	472
q16	512	431	432	431
q17	982	703	711	703
q18	7275	6946	6781	6781
q19	1403	962	1006	962
q20	699	349	326	326
q21	3960	3033	3087	3033
q22	1129	1026	1031	1026
Total cold run time: 111595 ms
Total hot run time: 38243 ms

----- Round 2, with runtime_filter_mode=off -----
q1	4344	4274	4238	4238
q2	370	266	269	266
q3	2831	2679	2632	2632
q4	1957	1712	1733	1712
q5	5422	5372	5373	5372
q6	217	131	129	129
q7	2087	1737	1762	1737
q8	3205	3355	3329	3329
q9	8400	8418	8357	8357
q10	3440	3201	3192	3192
q11	623	488	497	488
q12	794	625	604	604
q13	10806	3084	3113	3084
q14	306	288	285	285
q15	517	461	482	461
q16	517	474	481	474
q17	1790	1491	1489	1489
q18	7685	7406	7351	7351
q19	1661	1584	1443	1443
q20	2065	1840	1851	1840
q21	5486	5231	5202	5202
q22	1118	1038	1014	1014
Total cold run time: 65641 ms
Total hot run time: 54699 ms

@doris-robot
Copy link

TPC-DS: Total hot run time: 188394 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 25ffcb569fa59e3922f051f733fc75b38d0982c8, data reload: false

query1	909	373	380	373
query2	6486	1991	1895	1895
query3	6661	205	209	205
query4	30742	23175	23012	23012
query5	4168	513	497	497
query6	256	190	166	166
query7	4591	293	292	292
query8	275	221	205	205
query9	8821	2521	2530	2521
query10	449	299	269	269
query11	17819	14899	14962	14899
query12	148	101	95	95
query13	1618	388	362	362
query14	9488	7613	7454	7454
query15	275	167	175	167
query16	7603	464	437	437
query17	1660	564	551	551
query18	1342	287	286	286
query19	329	144	141	141
query20	119	106	111	106
query21	213	102	101	101
query22	4430	4171	4137	4137
query23	34042	33289	33327	33289
query24	11152	2915	2912	2912
query25	585	375	391	375
query26	1065	154	157	154
query27	2271	282	282	282
query28	7121	2072	2057	2057
query29	709	416	416	416
query30	304	156	149	149
query31	993	776	792	776
query32	93	51	55	51
query33	742	289	282	282
query34	967	467	479	467
query35	836	739	728	728
query36	1069	899	947	899
query37	146	85	85	85
query38	3959	3927	3957	3927
query39	1455	1395	1370	1370
query40	203	115	115	115
query41	49	51	47	47
query42	116	99	97	97
query43	505	473	473	473
query44	1320	788	757	757
query45	196	170	172	170
query46	1102	745	751	745
query47	1878	1798	1789	1789
query48	375	309	319	309
query49	1060	457	455	455
query50	824	408	413	408
query51	7108	6925	6838	6838
query52	101	89	91	89
query53	258	196	187	187
query54	921	466	468	466
query55	78	78	75	75
query56	290	285	270	270
query57	1250	1086	1090	1086
query58	254	235	262	235
query59	2926	2756	2969	2756
query60	302	282	273	273
query61	130	125	124	124
query62	838	667	665	665
query63	233	191	189	189
query64	4377	756	740	740
query65	3259	3180	3175	3175
query66	1300	374	354	354
query67	15572	15420	15331	15331
query68	4317	564	578	564
query69	428	281	293	281
query70	1197	1042	1145	1042
query71	347	292	286	286
query72	6750	4196	4144	4144
query73	755	334	343	334
query74	9345	8921	8830	8830
query75	3384	2728	2714	2714
query76	2591	982	1012	982
query77	442	330	324	324
query78	9968	9051	10282	9051
query79	1822	543	560	543
query80	1011	530	504	504
query81	596	230	229	229
query82	299	135	142	135
query83	217	149	157	149
query84	233	80	79	79
query85	1637	295	281	281
query86	486	300	292	292
query87	4373	4290	4217	4217
query88	3336	2358	2373	2358
query89	377	288	287	287
query90	1878	192	188	188
query91	128	103	98	98
query92	73	49	49	49
query93	1066	558	533	533
query94	922	299	312	299
query95	374	258	254	254
query96	577	270	266	266
query97	3229	3054	3040	3040
query98	224	202	194	194
query99	1630	1239	1252	1239
Total cold run time: 286748 ms
Total hot run time: 188394 ms

@doris-robot
Copy link

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

query1	0.05	0.04	0.04
query2	0.08	0.04	0.04
query3	0.23	0.05	0.04
query4	1.68	0.07	0.07
query5	0.48	0.49	0.51
query6	1.13	0.73	0.73
query7	0.02	0.01	0.02
query8	0.05	0.04	0.04
query9	0.54	0.49	0.50
query10	0.56	0.55	0.54
query11	0.16	0.11	0.11
query12	0.16	0.12	0.11
query13	0.60	0.59	0.59
query14	1.41	1.43	1.46
query15	0.87	0.82	0.82
query16	0.38	0.37	0.37
query17	1.05	1.05	1.03
query18	0.22	0.20	0.21
query19	1.85	1.87	1.72
query20	0.01	0.01	0.01
query21	15.42	0.67	0.67
query22	4.94	7.06	1.23
query23	18.29	1.46	1.29
query24	2.12	0.25	0.22
query25	0.16	0.09	0.08
query26	0.27	0.18	0.18
query27	0.07	0.07	0.08
query28	13.16	1.02	0.99
query29	12.63	3.39	3.39
query30	0.24	0.06	0.07
query31	2.86	0.41	0.40
query32	3.23	0.48	0.47
query33	2.97	2.98	3.02
query34	17.07	4.46	4.49
query35	4.48	4.51	4.46
query36	0.65	0.48	0.47
query37	0.19	0.16	0.15
query38	0.16	0.14	0.14
query39	0.05	0.03	0.04
query40	0.17	0.13	0.13
query41	0.10	0.05	0.05
query42	0.06	0.05	0.04
query43	0.05	0.04	0.04
Total cold run time: 110.87 s
Total hot run time: 30.88 s

loader = ClassLoader.getSystemClassLoader();
} else {
public UdfClassCache getClassCache(String className, String jarPath, String signature, long expirationTime,
Type funcRetType, Type... parameterTypes)
Copy link
Contributor

Choose a reason for hiding this comment

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

I check the failed two test case, not give jarPath in create function.
so pass jarPath = null to BE,
and maybe should give the path to custom_lib?

@morningman
Copy link
Contributor Author

run buildall

@github-actions github-actions bot added the approved Indicates a PR has been approved by one committer. label Sep 24, 2024
Copy link
Contributor

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

Copy link
Contributor

PR approved by anyone and no changes requested.

@morningman morningman merged commit 03dd32e into apache:master Sep 25, 2024
25 of 28 checks passed
gavinchou pushed a commit that referenced this pull request Sep 28, 2024
In this PR #34980, we cache the class load of java udf.
But when calling init() method, it is still very time consuming 
when calling `Class.forName()`.

This PR add a new class `UdfClassCache` to cache more things
so that the `init()` method will not cost too much time.
morningman added a commit to morningman/doris that referenced this pull request Feb 8, 2025
zhangstar333 added a commit that referenced this pull request Feb 13, 2025
### What problem does this PR solve?
Problem Summary:
in some user case,

- the udf-jars package have some resource file, it's maybe about
hundreds MBs,
so if every instances load the jar, it's easy to cause the BE JVM OOM.
- or in some udf-jars have some init operator cause many times, so wants
all instance could only init it's once.

follow up #40404
support class cache for java-udaf
morningman added a commit that referenced this pull request Feb 17, 2025
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