On Mon, 25 Apr 2022 14:33:13 GMT, Xue-Lei Andrew Fan <xue...@openjdk.org> wrote:

>> `SoftReference`s are guaranteed to survive one GC after use; beyond that 
>> their lifespan is determined by `SoftRefLRUPolicyMSPerMB` and the amount of 
>> memory available.
>
>> With all the above in mind I decided not to use `sun.security.util.Cache` 
>> here
> 
> I was not meant to use Cache and timeout for this update.
> 
> SoftReference and  this patch should work good in larger memory boxes.  
> Performance improvement sometimes is a trade-off game between memory and CPU. 
> Did you have a chance to check the performance in the limited memory 
> circumstance?  like '-mx64M".

I run a few tests:
`-Xmx16m`, with this patch, still better than the original version:

Benchmark                 (resume)  (tlsVersion)   Mode  Cnt     Score     
Error  Units
SSLHandshake.doHandshake      true       TLSv1.2  thrpt    5  4477.444 ± 
375.975  ops/s
SSLHandshake.doHandshake      true           TLS  thrpt    5   681.471 ±  
72.531  ops/s
SSLHandshake.doHandshake     false       TLSv1.2  thrpt    5   335.366 ±  
89.056  ops/s
SSLHandshake.doHandshake     false           TLS  thrpt    5   308.711 ±  
90.134  ops/s


`-Xmx8m`, before patch:

Benchmark                 (resume)  (tlsVersion)   Mode  Cnt    Score    Error  
Units
SSLHandshake.doHandshake      true       TLSv1.2  thrpt    5  153.760 ± 12.025  
ops/s
SSLHandshake.doHandshake      true           TLS  thrpt    5   70.700 ±  7.506  
ops/s
SSLHandshake.doHandshake     false       TLSv1.2  thrpt    5   67.459 ±  4.325  
ops/s
SSLHandshake.doHandshake     false           TLS  thrpt    5   64.695 ±  1.647  
ops/s

after:

Benchmark                 (resume)  (tlsVersion)   Mode  Cnt    Score    Error  
Units
SSLHandshake.doHandshake      true       TLSv1.2  thrpt    5  557.324 ± 50.269  
ops/s
SSLHandshake.doHandshake      true           TLS  thrpt    5  155.258 ± 13.866  
ops/s
SSLHandshake.doHandshake     false       TLSv1.2  thrpt    5  181.755 ± 29.319  
ops/s
SSLHandshake.doHandshake     false           TLS  thrpt    5  120.627 ± 25.832  
ops/s

Much slower, but still faster with the patch.
With `-Xmx4m` the test failed with OOM.

-------------

PR: https://git.openjdk.java.net/jdk/pull/8349

Reply via email to