Skip to content

[fix] remove useless const_cast and explain const_cast(3) - #56441

Merged
yiguolei merged 7 commits into
apache:masterfrom
wumeibanfa:remove_const_3
Oct 26, 2025
Merged

yiguolei merged 7 commits into
apache:masterfrom
wumeibanfa:remove_const_3

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

@wumeibanfa

Copy link
Copy Markdown
Contributor Author

run buildall

@hello-stephen

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?

@doris-robot

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

query1	0.05	0.05	0.04
query2	0.09	0.05	0.05
query3	0.24	0.08	0.08
query4	1.60	0.11	0.11
query5	0.27	0.26	0.25
query6	1.22	0.66	0.64
query7	0.03	0.02	0.02
query8	0.05	0.04	0.04
query9	0.60	0.53	0.51
query10	0.59	0.58	0.57
query11	0.17	0.11	0.11
query12	0.15	0.12	0.12
query13	0.63	0.65	0.62
query14	1.03	1.05	1.05
query15	0.86	0.84	0.86
query16	0.44	0.40	0.39
query17	1.08	1.05	1.07
query18	0.22	0.20	0.20
query19	1.97	1.79	1.83
query20	0.01	0.01	0.02
query21	15.41	0.93	0.58
query22	0.78	1.25	0.97
query23	14.72	1.38	0.61
query24	7.11	1.88	0.54
query25	0.46	0.24	0.12
query26	0.78	0.17	0.13
query27	0.06	0.05	0.06
query28	9.12	1.36	0.95
query29	12.57	3.85	3.25
query30	0.28	0.14	0.12
query31	2.83	0.58	0.39
query32	3.24	0.55	0.48
query33	3.14	3.12	3.08
query34	16.16	5.52	4.87
query35	4.92	4.93	4.89
query36	0.71	0.51	0.51
query37	0.10	0.08	0.07
query38	0.07	0.05	0.05
query39	0.04	0.03	0.03
query40	0.17	0.16	0.14
query41	0.08	0.04	0.03
query42	0.04	0.03	0.03
query43	0.04	0.04	0.04
Total cold run time: 104.13 s
Total hot run time: 30.42 s

@hello-stephen

Copy link
Copy Markdown
Contributor

BE UT Coverage Report

Increment line coverage 82.80% (77/93) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 52.41% (17617/33612)
Line Coverage 37.62% (160029/425341)
Region Coverage 32.19% (122125/379393)
Branch Coverage 33.52% (53535/159698)

@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 92.47% (86/93) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 71.17% (23354/32815)
Line Coverage 57.57% (244202/424185)
Region Coverage 53.08% (204048/384423)
Branch Coverage 54.57% (87507/160347)

@zclllyybb
zclllyybb requested a review from yiguolei October 12, 2025 06:52
Comment thread be/src/olap/rowset/segment_creator.cpp Resolved
Comment thread be/src/olap/rowset/segment_v2/page_io.h Resolved
@wumeibanfa

Copy link
Copy Markdown
Contributor Author

run buildall

@doris-robot

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

query1	0.06	0.06	0.05
query2	0.09	0.06	0.05
query3	0.25	0.08	0.09
query4	1.61	0.12	0.12
query5	0.28	0.27	0.27
query6	1.17	0.66	0.65
query7	0.03	0.03	0.02
query8	0.06	0.04	0.04
query9	0.66	0.55	0.52
query10	0.56	0.56	0.58
query11	0.17	0.12	0.11
query12	0.15	0.12	0.12
query13	0.63	0.63	0.62
query14	1.03	1.03	1.01
query15	0.88	0.85	0.86
query16	0.39	0.41	0.41
query17	1.04	1.07	1.07
query18	0.22	0.20	0.20
query19	1.91	1.81	1.80
query20	0.01	0.02	0.02
query21	15.43	0.97	0.58
query22	0.76	1.11	0.61
query23	15.09	1.43	0.64
query24	7.07	1.54	0.63
query25	0.47	0.16	0.11
query26	0.64	0.16	0.15
query27	0.06	0.06	0.06
query28	9.70	1.44	0.93
query29	12.65	3.96	3.25
query30	0.28	0.13	0.12
query31	2.84	0.60	0.40
query32	3.26	0.57	0.48
query33	3.07	3.15	3.11
query34	16.26	5.49	4.88
query35	4.99	4.92	4.96
query36	0.70	0.52	0.51
query37	0.10	0.07	0.06
query38	0.07	0.05	0.04
query39	0.04	0.03	0.03
query40	0.18	0.15	0.15
query41	0.08	0.03	0.03
query42	0.03	0.03	0.03
query43	0.05	0.04	0.03
Total cold run time: 105.02 s
Total hot run time: 30.32 s

@doris-robot

Copy link
Copy Markdown

BE UT Coverage Report

Increment line coverage 60.00% (18/30) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 52.53% (17751/33793)
Line Coverage 37.71% (161197/427452)
Region Coverage 32.19% (123113/382407)
Branch Coverage 33.59% (53995/160753)

@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 83.33% (25/30) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 71.16% (23561/33111)
Line Coverage 57.58% (245878/427042)
Region Coverage 52.80% (204468/387239)
Branch Coverage 54.54% (88125/161568)

@wumeibanfa

Copy link
Copy Markdown
Contributor Author

run p0

@wumeibanfa

Copy link
Copy Markdown
Contributor Author

run cloud_p0

@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 83.33% (25/30) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 71.16% (23561/33111)
Line Coverage 57.58% (245887/427042)
Region Coverage 52.79% (204414/387239)
Branch Coverage 54.54% (88117/161568)

1 similar comment
@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 83.33% (25/30) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 71.16% (23561/33111)
Line Coverage 57.58% (245887/427042)
Region Coverage 52.79% (204414/387239)
Branch Coverage 54.54% (88117/161568)

@wumeibanfa

Copy link
Copy Markdown
Contributor Author

run p0

@wumeibanfa
wumeibanfa requested a review from yiguolei October 14, 2025 04:11
@wumeibanfa

Copy link
Copy Markdown
Contributor Author

run buildall

@doris-robot

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

query1	1073	436	407	407
query2	6558	1658	1684	1658
query3	6750	224	225	224
query4	26327	23876	23607	23607
query5	5310	665	487	487
query6	344	243	234	234
query7	4671	510	309	309
query8	311	299	279	279
query9	8756	2589	2554	2554
query10	532	353	293	293
query11	15536	15143	14877	14877
query12	188	129	121	121
query13	1705	574	454	454
query14	11685	9305	9310	9305
query15	266	190	174	174
query16	7795	676	540	540
query17	1619	801	659	659
query18	2664	497	343	343
query19	265	201	191	191
query20	145	143	143	143
query21	240	137	136	136
query22	4646	4739	4488	4488
query23	34777	33872	33920	33872
query24	8490	2483	2673	2483
query25	575	517	447	447
query26	1220	279	160	160
query27	2770	548	425	425
query28	5575	2293	2266	2266
query29	803	668	485	485
query30	303	226	200	200
query31	926	839	780	780
query32	80	82	71	71
query33	583	376	366	366
query34	829	909	539	539
query35	849	907	794	794
query36	1003	991	883	883
query37	136	117	87	87
query38	3560	3506	3490	3490
query39	1463	1437	1430	1430
query40	222	128	117	117
query41	59	56	59	56
query42	127	108	112	108
query43	484	491	476	476
query44	1362	863	822	822
query45	180	176	170	170
query46	840	992	642	642
query47	1751	1776	1706	1706
query48	399	428	315	315
query49	797	511	400	400
query50	680	698	414	414
query51	4023	3915	3853	3853
query52	110	107	100	100
query53	236	269	198	198
query54	610	590	542	542
query55	94	93	90	90
query56	336	344	316	316
query57	1170	1186	1109	1109
query58	286	284	267	267
query59	2578	2597	2590	2590
query60	341	350	321	321
query61	158	154	143	143
query62	801	761	683	683
query63	238	194	193	193
query64	4373	1130	892	892
query65	4068	3971	3989	3971
query66	1073	434	318	318
query67	15408	15346	14917	14917
query68	9095	903	596	596
query69	512	340	290	290
query70	1356	1268	1257	1257
query71	588	361	312	312
query72	5887	4774	4826	4774
query73	701	576	353	353
query74	9175	8800	8621	8621
query75	4456	3365	2859	2859
query76	3769	1167	769	769
query77	829	415	317	317
query78	9581	9722	8892	8892
query79	5053	800	596	596
query80	682	571	499	499
query81	489	272	224	224
query82	610	232	137	137
query83	303	292	256	256
query84	311	113	101	101
query85	874	463	433	433
query86	336	290	284	284
query87	3719	3746	3668	3668
query88	2893	2279	2220	2220
query89	461	325	303	303
query90	2064	229	241	229
query91	158	158	131	131
query92	82	72	67	67
query93	2705	992	631	631
query94	699	447	345	345
query95	404	324	307	307
query96	495	603	285	285
query97	2915	3015	2893	2893
query98	230	217	215	215
query99	1439	1433	1317	1317
Total cold run time: 287003 ms
Total hot run time: 190171 ms

@doris-robot

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

query1	0.06	0.05	0.04
query2	0.09	0.05	0.06
query3	0.25	0.09	0.08
query4	1.61	0.12	0.12
query5	0.29	0.26	0.26
query6	1.19	0.66	0.65
query7	0.03	0.04	0.02
query8	0.06	0.05	0.05
query9	0.63	0.52	0.51
query10	0.58	0.58	0.57
query11	0.16	0.11	0.12
query12	0.15	0.12	0.13
query13	0.65	0.62	0.61
query14	1.04	1.05	1.05
query15	0.85	0.87	0.87
query16	0.40	0.40	0.40
query17	1.05	1.08	1.09
query18	0.21	0.20	0.20
query19	1.97	1.80	1.82
query20	0.01	0.01	0.02
query21	15.44	0.91	0.58
query22	0.75	1.26	0.68
query23	14.84	1.43	0.61
query24	6.88	1.56	0.63
query25	0.46	0.25	0.09
query26	0.56	0.15	0.15
query27	0.07	0.06	0.05
query28	9.22	1.38	0.93
query29	12.57	3.97	3.25
query30	0.29	0.14	0.11
query31	2.82	0.62	0.38
query32	3.27	0.55	0.48
query33	3.14	3.10	3.09
query34	16.11	5.48	4.88
query35	4.97	4.99	4.94
query36	0.69	0.52	0.50
query37	0.11	0.07	0.07
query38	0.06	0.05	0.04
query39	0.04	0.03	0.03
query40	0.18	0.14	0.13
query41	0.09	0.03	0.03
query42	0.04	0.02	0.02
query43	0.05	0.04	0.03
Total cold run time: 103.93 s
Total hot run time: 30.3 s

@wumeibanfa

Copy link
Copy Markdown
Contributor Author

run beut

@hello-stephen

Copy link
Copy Markdown
Contributor

BE UT Coverage Report

Increment line coverage 73.68% (14/19) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 52.61% (17876/33977)
Line Coverage 37.83% (162133/428592)
Region Coverage 32.26% (123715/383460)
Branch Coverage 33.66% (54192/160987)

@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 84.21% (16/19) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 71.40% (23782/33310)
Line Coverage 57.77% (247467/428344)
Region Coverage 52.83% (205214/388418)
Branch Coverage 54.59% (88375/161882)

@wumeibanfa
wumeibanfa requested a review from yiguolei October 21, 2025 08:48
@github-actions github-actions Bot added the approved Indicates a PR has been approved by one committer. label Oct 26, 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 955d04d into apache:master Oct 26, 2025
12 checks passed
github-actions Bot pushed a commit that referenced this pull request Oct 26, 2025
### 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 27, 2025
dwdwqfwe pushed a commit to dwdwqfwe/doris that referenced this pull request Oct 31, 2025
### What problem does this PR solve?
 go through whole be/ and find all const_cast

Issue Number: apache#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 -->
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.

5 participants