wildfly-security / wildfly-openssl

Generic OpenSSL bindings for Java
Apache License 2.0
81 stars 72 forks source link

change ByteBuffer allocation/de-allocation to pool based #120

Closed heyuanliu-intel closed 2 years ago

heyuanliu-intel commented 2 years ago

Fix the ByteBuffer allocation/de-allocation performance bottleneck.

Please refer to #119

Please refer to this project: https://github.com/heyuanliu-intel/ByteBufferPerformance Based on the pool based allocation/de-allocation, we can get 4X performance improvement for the Airlift benchmarking.

stuartwdouglas commented 2 years ago

This approach needs to be pluggable, this pattern can result in non-trivial memory leaks if the engine is used by short lived threads. Wildfly/EAP already have their own buffer pools as well, and it would be better to re-use these if they are sized correctly.

heyuanliu-intel commented 2 years ago

So we can make the pool shared by all the threads instead of thread local object to avoid memory leaks issue for short lived threads.

If Wildfly already have the buffer pools. Could anyone help to integrate it to Wildfly-OpenSSL to fixing the performance bottleneck issue ?

tristantarrant commented 2 years ago

Maybe it should also use a ConcurrentSkipListMap to avoid the synchronized usage.

heyuanliu-intel commented 2 years ago

Reuse the wildfly-openssl provided DefaultByteBufferPool to rewrite the code.