Skip to content

数组预分配优化及统一数组预分配策略#290

Open
MiKKiYang wants to merge 1 commit intosecretflow:mainfrom
MiKKiYang:main
Open

数组预分配优化及统一数组预分配策略#290
MiKKiYang wants to merge 1 commit intosecretflow:mainfrom
MiKKiYang:main

Conversation

@MiKKiYang
Copy link
Contributor

多处代码中分别出现随意的数组预分配处理(有的按照0,有的按照.size()取大小),较为不统一,当前修复采用性能较高的数组预分配同size()处理,理由见如下代码分析:

image image

预分配同样大小数组可直接调用jvm实现的native方法system.arraycopy,可进行性能提升;
给0值则需要newInstance一个对象后再调用native方法。

Signed-off-by: MikkiYang <hecy7@asiainfo.com>
Copy link
Collaborator

@haha-zwx-ooo haha-zwx-ooo left a comment

Choose a reason for hiding this comment

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

lgtm

@MiKKiYang MiKKiYang requested a review from haha-zwx-ooo July 21, 2025 03:54
Copy link
Collaborator

@wenyuanhust wenyuanhust left a comment

Choose a reason for hiding this comment

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

请问有实际测试性能提升的幅度吗?如果提升不明显,不建议修改。原有代码更简洁

@MiKKiYang
Copy link
Contributor Author

MiKKiYang commented Jul 25, 2025

请问有实际测试性能提升的幅度吗?如果提升不明显,不建议修改。原有代码更简洁

@wenyuanhust

具体性能提升幅度未测试,因为secretPad本身只是属于隐语全栈技术(pad -> kuscia -> flow -> spu)的产品层,此处的性能影响较之全链路近乎于没有;

该修改主要关注点不在于性能,也跟简洁无关,而在于代码统一,当前项目多处代码分别出现过于随意的数组预分配处理方式,有的按照0,有的按照.size()取大小,建议统一为一种。

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.

3 participants