tarantool / cartridge-java

Tarantool Cartridge Java driver for Tarantool versions 1.10+ based on Netty framework
https://tarantool.io
Other
27 stars 11 forks source link

Replace streams with loops in DefaultMessagePackMapper #439

Closed akudiyar closed 7 months ago

akudiyar commented 10 months ago

toValue and fromValue methods in DefaultMessagePackMapper are hot spots as they are called on each request. This code was first written using Java streams, but while it allowed to make the code more readable, the streams are not very well-suitable for this task. The Java streams work better when we can execute the chained lambda functions in parallel on an executor, but are worse when replacing the normal for loops - they add significant overhead because of a lot of created auxiliary classes and objects in runtime.

Now as the DefaultMessagePackMapper code is stable we can replace the stream-based code with more optimized loop-based code.

akudiyar commented 8 months ago

Waits for #438 to be merged.

akudiyar commented 7 months ago

Changelog line added in https://github.com/tarantool/cartridge-java/pull/453

I guess we can merge this PR as it is.