<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
BTW, it may worthy to track the development of the Frozen Arrays JEP:
<div class=""> <a href="https://openjdk.java.net/jeps/8261007" class="">https://openjdk.java.net/jeps/8261007</a></div>
<div class=""><br class="">
</div>
<div class="">Xuelei<br class="">
<div><br class="">
<blockquote type="cite" class="">
<div class="">On Jul 9, 2021, at 11:21 AM, Xuelei Fan <<a href="mailto:xuelei.fan@oracle.com" class="">xuelei.fan@oracle.com</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div class="">Hi Clive,<br class="">
<br class="">
It’s a good point to me! Did you have the numbers about the performance impact?<br class="">
<br class="">
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.<br class="">
<br class="">
Thanks,<br class="">
Xuelei<br class="">
<br class="">
<blockquote type="cite" class="">On Jul 9, 2021, at 10:52 AM, Verghese, Clive <<a href="mailto:verghese@amazon.com" class="">verghese@amazon.com</a>> wrote:<br class="">
<br class="">
Hi <br class="">
<br class="">
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.
<br class="">
<br class="">
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.
<br class="">
<br class="">
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.
<br class="">
<br class="">
Regards,<br class="">
Clive Verghese <br class="">
<br class="">
1 : <a href="https://github.com/openjdk/jdk/blob/master/src/java.base/share/classes/sun/security/ssl/CipherSuite.java" class="">
https://github.com/openjdk/jdk/blob/master/src/java.base/share/classes/sun/security/ssl/CipherSuite.java</a><br class="">
2 : <a href="http://mail.openjdk.java.net/pipermail/compiler-dev/2018-July/012242.html" class="">
http://mail.openjdk.java.net/pipermail/compiler-dev/2018-July/012242.html</a><br class="">
3 : <a href="https://github.com/cliveverghese/jdk/commit/8b34c06d8305ef9cb6a790e4cc8ca169c2fc9d79" class="">
https://github.com/cliveverghese/jdk/commit/8b34c06d8305ef9cb6a790e4cc8ca169c2fc9d79</a><br class="">
<br class="">
<br class="">
</blockquote>
<br class="">
</div>
</div>
</blockquote>
</div>
<br class="">
</div>
</body>
</html>