BTW, it may worthy to track the development of the Frozen Arrays JEP:
    https://openjdk.java.net/jeps/8261007

Xuelei

On Jul 9, 2021, at 11:21 AM, Xuelei Fan 
<[email protected]<mailto:[email protected]>> wrote:

Hi Clive,

It’s a good point to me!  Did you have the numbers about the performance impact?

Considering the size of CipherSuites, I think it is good to make an 
improvement.  As we are already here, may be we could consider if we could make 
further performance improvement for searching as well.

Thanks,
Xuelei

On Jul 9, 2021, at 10:52 AM, Verghese, Clive 
<[email protected]<mailto:[email protected]>> wrote:

Hi

We have identified large number of allocations in CipherSuites[1]. The root 
cause for the allocations is that in the `CipherSuite.values` call in `nameof` 
and `valueof` functions. These functions are called by the 
SSLAlgorithmDecomposer and in SSLEngineImpl. The enumeration values functions 
clones the array before returning. A previous discussion on the compiler-dev 
channel[2] describes why the values function returns a clone. We would like to 
propose that the CipherSuite.values be stored in a `private static final` field 
[3]. This would prevent the need to clone the array for each lookup across the 
enum.

The proposed change stores the ciphers as an array itself. The other 
alternative would be to store the values as a HashMap. However, I feel that 
this would not be optimal due to the ordering of the Enumeration.

Looking for your feedback and recommendations. If the proposal look good, I can 
go ahead and create a JBS issue and submit a PR for the same.

Regards,
Clive Verghese

1 : 
https://github.com/openjdk/jdk/blob/master/src/java.base/share/classes/sun/security/ssl/CipherSuite.java
2 : http://mail.openjdk.java.net/pipermail/compiler-dev/2018-July/012242.html
3 : 
https://github.com/cliveverghese/jdk/commit/8b34c06d8305ef9cb6a790e4cc8ca169c2fc9d79




Reply via email to