PERFORMANCE! Why you should use Message.reset() in Solace APIs..!
Hi Developers! Want to go fast? Faster, anyway? Read on...
I'm just putting the finishing touches on a new bunch of Solace Java (JCSMP) samples, and have been doing a bit of performance testing with them. They are still meant to be fairly simple and straightforward, and don't try to maximize absolute throughput performance, but they're pretty quick. When publishing Direct messages in a loop, I was wondering what the difference would be between creating new Message objects each time, or reusing the same ones and calling
reset() on each loop, and reusing it on the next loop. Well...
Creating new Message object each loop
Published msgs/s: 251,419 Published msgs/s: 255,510 Published msgs/s: 256,729 Published msgs/s: 258,469 Published msgs/s: 256,312
Using Message.reset() on each loop
Published msgs/s: 323,841 Published msgs/s: 316,270 Published msgs/s: 327,877 Published msgs/s: 336,641 Published msgs/s: 325,477 Published msgs/s: 326,037
Huh! About a 25% increase in speed. Not bad..! Also, when Java's GC would start to kick in, that would definitely periodically impact performance, having to clean up all these unused Message objects.
Technical notes: JCSMP API, single thread, Direct messages, 100 byte payload, dynamic topics, Intel(R) Core(TM) i7-7820X CPU @ 3.60GHz, 1 GbE LAN to Solace broker
Code is here: https://github.com/aaron-613/solace-samples-jcsmp/blob/master/src/main/java/com/solace/samples/DirectPublisher.java