Skip to content

[fix] remove useless const_cast and explain const_cast for vec (3) - #56600

Merged
yiguolei merged 3 commits into
apache:masterfrom
wumeibanfa:remove_vec_const3
Oct 10, 2025
Merged

yiguolei merged 3 commits into
apache:masterfrom
wumeibanfa:remove_vec_const3

Conversation

@wumeibanfa

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

go through whole be/ and find all const_cast

Issue Number: #55057

Problem Summary:

  1. remove useless const_cast
  2. explain why using const_cast does not result in undefined behavior
  3. don't modify some const_cast
    (1) some code in DBUG_EXECUTE_IF or test file
    (2) underlying data structures, such as cow
    (3) const_cast<const T*>

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

@Thearas

Thearas commented Sep 28, 2025

Copy link
Copy Markdown
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?

@wumeibanfa

Copy link
Copy Markdown
Contributor Author

run buildall

@hello-stephen

Copy link
Copy Markdown
Contributor

BE UT Coverage Report

Increment line coverage 62.94% (90/143) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 52.42% (17637/33643)
Line Coverage 37.63% (160189/425655)
Region Coverage 32.13% (122215/380356)
Branch Coverage 33.52% (53598/159903)

@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 84.62% (121/143) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 71.23% (23394/32841)
Line Coverage 57.65% (244727/424485)
Region Coverage 53.02% (203995/384764)
Branch Coverage 54.72% (87826/160496)

@wumeibanfa

Copy link
Copy Markdown
Contributor Author

run nonConcurrent

@wumeibanfa

Copy link
Copy Markdown
Contributor Author

run performance

@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 78.29% (101/129) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 71.18% (23377/32841)
Line Coverage 57.61% (244526/424485)
Region Coverage 52.98% (203867/384764)
Branch Coverage 54.65% (87717/160496)

@doris-robot

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

query1	0.05	0.05	0.05
query2	0.09	0.05	0.06
query3	0.25	0.09	0.08
query4	1.62	0.12	0.12
query5	0.28	0.28	0.25
query6	1.19	0.67	0.66
query7	0.03	0.03	0.03
query8	0.06	0.05	0.04
query9	0.64	0.52	0.51
query10	0.58	0.58	0.57
query11	0.19	0.12	0.11
query12	0.16	0.13	0.12
query13	0.62	0.62	0.62
query14	1.03	1.04	1.03
query15	0.87	0.87	0.87
query16	0.40	0.40	0.39
query17	1.06	1.05	1.06
query18	0.22	0.20	0.20
query19	1.95	1.86	1.87
query20	0.02	0.02	0.02
query21	15.42	0.91	0.57
query22	0.75	1.30	0.69
query23	14.83	1.40	0.67
query24	7.34	0.87	1.22
query25	0.44	0.21	0.13
query26	0.59	0.15	0.14
query27	0.06	0.06	0.05
query28	9.22	1.37	0.94
query29	12.57	3.86	3.22
query30	0.29	0.14	0.12
query31	2.83	0.60	0.39
query32	3.24	0.57	0.47
query33	3.14	3.08	3.09
query34	16.19	5.49	4.80
query35	4.93	4.91	4.91
query36	0.70	0.52	0.51
query37	0.10	0.08	0.07
query38	0.08	0.05	0.04
query39	0.04	0.03	0.02
query40	0.17	0.15	0.14
query41	0.08	0.03	0.04
query42	0.04	0.04	0.03
query43	0.05	0.04	0.03
Total cold run time: 104.41 s
Total hot run time: 30.55 s

Comment thread be/src/exprs/math_functions.h Resolved
Comment thread be/src/udf/udf.cpp Resolved
Comment thread be/src/udf/udf.h Resolved
@wumeibanfa

Copy link
Copy Markdown
Contributor Author

run buildall

@doris-robot

Copy link
Copy Markdown
TPC-DS: Total hot run time: 190823 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 efb027912a80842f2c9b0bf8d5404dbb379eb234, data reload: false

query1	1067	426	411	411
query2	6550	1725	1656	1656
query3	6756	234	234	234
query4	26709	23846	23527	23527
query5	5156	665	486	486
query6	362	245	230	230
query7	4659	497	315	315
query8	315	275	282	275
query9	8743	2632	2586	2586
query10	560	366	292	292
query11	15302	15139	15694	15139
query12	194	131	127	127
query13	1860	578	531	531
query14	11980	9635	9667	9635
query15	276	209	182	182
query16	7975	688	613	613
query17	1644	808	666	666
query18	2150	440	339	339
query19	295	205	205	205
query20	153	126	123	123
query21	342	271	153	153
query22	4458	4906	4598	4598
query23	34682	33808	33309	33309
query24	8315	2396	2401	2396
query25	561	498	442	442
query26	1035	265	153	153
query27	2693	497	349	349
query28	4224	2176	2147	2147
query29	688	612	501	501
query30	294	225	197	197
query31	897	840	748	748
query32	74	70	66	66
query33	579	387	315	315
query34	790	855	516	516
query35	774	832	753	753
query36	997	1021	946	946
query37	124	111	92	92
query38	3565	3550	3517	3517
query39	1502	1396	1429	1396
query40	219	130	112	112
query41	62	57	58	57
query42	126	113	112	112
query43	468	485	477	477
query44	1309	827	818	818
query45	199	181	174	174
query46	846	999	641	641
query47	1765	1855	1744	1744
query48	392	425	322	322
query49	746	520	422	422
query50	646	693	404	404
query51	4011	4043	3845	3845
query52	113	108	101	101
query53	234	279	206	206
query54	594	599	518	518
query55	89	83	86	83
query56	333	311	305	305
query57	1156	1206	1140	1140
query58	286	274	274	274
query59	2563	2657	2625	2625
query60	363	340	317	317
query61	195	158	152	152
query62	810	772	682	682
query63	237	189	193	189
query64	3880	1172	824	824
query65	4044	3972	3995	3972
query66	938	431	341	341
query67	15503	15505	15041	15041
query68	9138	991	600	600
query69	497	332	289	289
query70	1375	1330	1354	1330
query71	495	339	319	319
query72	5624	4967	4900	4900
query73	702	584	360	360
query74	9116	8886	8883	8883
query75	4454	3419	2858	2858
query76	3714	1151	746	746
query77	904	425	323	323
query78	9566	9756	8880	8880
query79	1957	814	590	590
query80	691	563	513	513
query81	493	270	285	270
query82	485	163	130	130
query83	297	279	263	263
query84	311	125	98	98
query85	887	464	429	429
query86	334	336	322	322
query87	3810	3776	3684	3684
query88	2809	2317	2252	2252
query89	403	336	304	304
query90	2027	232	226	226
query91	159	177	136	136
query92	88	69	64	64
query93	1183	977	647	647
query94	693	443	334	334
query95	398	326	313	313
query96	484	575	281	281
query97	2930	2985	2875	2875
query98	239	212	216	212
query99	1437	1417	1328	1328
Total cold run time: 279127 ms
Total hot run time: 190823 ms

@doris-robot

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

query1	0.06	0.05	0.06
query2	0.09	0.05	0.06
query3	0.25	0.09	0.08
query4	1.61	0.11	0.12
query5	0.27	0.26	0.25
query6	1.19	0.66	0.65
query7	0.03	0.02	0.02
query8	0.06	0.05	0.04
query9	0.64	0.52	0.51
query10	0.59	0.59	0.57
query11	0.16	0.12	0.12
query12	0.15	0.12	0.12
query13	0.64	0.63	0.62
query14	1.02	1.05	1.04
query15	0.88	0.85	0.88
query16	0.41	0.40	0.38
query17	1.05	1.04	1.03
query18	0.22	0.20	0.20
query19	1.98	1.82	1.83
query20	0.02	0.02	0.02
query21	15.42	0.94	0.57
query22	0.76	1.24	0.76
query23	14.77	1.39	0.67
query24	7.75	1.22	0.33
query25	0.29	0.13	0.09
query26	0.59	0.16	0.13
query27	0.08	0.06	0.04
query28	8.59	1.36	0.93
query29	12.55	3.93	3.24
query30	0.28	0.14	0.11
query31	2.83	0.61	0.39
query32	3.23	0.57	0.47
query33	3.17	3.05	3.04
query34	16.13	5.53	4.85
query35	4.91	4.94	4.87
query36	0.70	0.52	0.51
query37	0.11	0.08	0.07
query38	0.07	0.04	0.04
query39	0.04	0.03	0.03
query40	0.17	0.15	0.14
query41	0.09	0.03	0.03
query42	0.04	0.02	0.03
query43	0.04	0.03	0.04
Total cold run time: 103.93 s
Total hot run time: 29.89 s

@hello-stephen

Copy link
Copy Markdown
Contributor

BE UT Coverage Report

Increment line coverage 55.26% (42/76) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 52.48% (17706/33739)
Line Coverage 37.65% (160732/426858)
Region Coverage 32.14% (122754/381898)
Branch Coverage 33.54% (53840/160525)

@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 81.58% (62/76) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 71.16% (23524/33057)
Line Coverage 57.64% (245781/426427)
Region Coverage 52.88% (204508/386726)
Branch Coverage 54.56% (88024/161336)

@wumeibanfa

Copy link
Copy Markdown
Contributor Author

run p0

@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 81.58% (62/76) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 71.16% (23525/33057)
Line Coverage 57.64% (245773/426427)
Region Coverage 52.85% (204400/386726)
Branch Coverage 54.56% (88024/161336)

@wumeibanfa

Copy link
Copy Markdown
Contributor Author

run p0

@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 81.58% (62/76) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 71.16% (23524/33057)
Line Coverage 57.64% (245773/426427)
Region Coverage 52.87% (204463/386726)
Branch Coverage 54.56% (88020/161336)

@github-actions github-actions Bot added the approved Indicates a PR has been approved by one committer. label Oct 10, 2025
@github-actions

Copy link
Copy Markdown
Contributor

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

@github-actions

Copy link
Copy Markdown
Contributor

PR approved by anyone and no changes requested.

@yiguolei
yiguolei merged commit 066fb58 into apache:master Oct 10, 2025
12 checks passed
github-actions Bot pushed a commit that referenced this pull request Oct 10, 2025
…56600)

### What problem does this PR solve?
 go through whole be/ and find all const_cast

Issue Number: #55057 

Problem Summary:
1. remove useless const_cast
2. explain why using const_cast does not result in undefined behavior
3. don't modify some const_cast
    (1) some code in DBUG_EXECUTE_IF or test file
    (2) underlying data structures, such as cow
    (3) const_cast<const T*>


### Release note

None

### 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)
    - [x] No need to test or manual test. Explain why:
- [ ] This is a refactor/code format and no logic has been changed.
        - [x] Previous test can cover this change.
        - [ ] No code files have been changed.
        - [ ] Other reason <!-- Add your reason?  -->

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

- Does this need documentation?
    - [x] 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 -->
yiguolei pushed a commit that referenced this pull request Oct 11, 2025
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.1-merged reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants