Essentially make publish a zero alloc. Use c.mqtt.pp as the parser publish packet structure. Messages were initially copied because MQTT messages don't have CR_LF but was adding it so that it worked for NATS pub/subs and MQTT pub/subs. Now an MQTT producer sending to NATS sub will queue CR_LF after payload. Here is result of benchcmp for MQTT pub runs only: ``` benchmark old ns/op new ns/op delta BenchmarkMQTT_QoS0_Pub_______0b_Payload-8 157 55.6 -64.59% BenchmarkMQTT_QoS0_Pub_______8b_Payload-8 167 61.0 -63.47% BenchmarkMQTT_QoS0_Pub______32b_Payload-8 181 65.3 -63.92% BenchmarkMQTT_QoS0_Pub_____128b_Payload-8 243 78.1 -67.86% BenchmarkMQTT_QoS0_Pub_____256b_Payload-8 298 95.0 -68.12% BenchmarkMQTT_QoS0_Pub_______1K_Payload-8 604 224 -62.91% BenchmarkMQTT_QoS1_Pub_______0b_Payload-8 1713 1314 -23.29% BenchmarkMQTT_QoS1_Pub_______8b_Payload-8 1703 1311 -23.02% BenchmarkMQTT_QoS1_Pub______32b_Payload-8 1722 1345 -21.89% BenchmarkMQTT_QoS1_Pub_____128b_Payload-8 2105 1432 -31.97% BenchmarkMQTT_QoS1_Pub_____256b_Payload-8 2148 1503 -30.03% BenchmarkMQTT_QoS1_Pub_______1K_Payload-8 3024 1889 -37.53% benchmark old MB/s new MB/s speedup BenchmarkMQTT_QoS0_Pub_______0b_Payload-8 31.76 89.91 2.83x BenchmarkMQTT_QoS0_Pub_______8b_Payload-8 77.79 213.01 2.74x BenchmarkMQTT_QoS0_Pub______32b_Payload-8 204.52 566.26 2.77x BenchmarkMQTT_QoS0_Pub_____128b_Payload-8 550.65 1715.96 3.12x BenchmarkMQTT_QoS0_Pub_____256b_Payload-8 877.77 2757.16 3.14x BenchmarkMQTT_QoS0_Pub_______1K_Payload-8 1705.02 4607.72 2.70x BenchmarkMQTT_QoS1_Pub_______0b_Payload-8 6.42 8.37 1.30x BenchmarkMQTT_QoS1_Pub_______8b_Payload-8 11.16 14.49 1.30x BenchmarkMQTT_QoS1_Pub______32b_Payload-8 24.97 31.97 1.28x BenchmarkMQTT_QoS1_Pub_____128b_Payload-8 66.52 97.74 1.47x BenchmarkMQTT_QoS1_Pub_____256b_Payload-8 124.78 178.27 1.43x BenchmarkMQTT_QoS1_Pub_______1K_Payload-8 342.64 548.32 1.60x benchmark old allocs new allocs delta BenchmarkMQTT_QoS0_Pub_______0b_Payload-8 3 0 -100.00% BenchmarkMQTT_QoS0_Pub_______8b_Payload-8 3 0 -100.00% BenchmarkMQTT_QoS0_Pub______32b_Payload-8 3 0 -100.00% BenchmarkMQTT_QoS0_Pub_____128b_Payload-8 4 0 -100.00% BenchmarkMQTT_QoS0_Pub_____256b_Payload-8 4 0 -100.00% BenchmarkMQTT_QoS0_Pub_______1K_Payload-8 4 0 -100.00% BenchmarkMQTT_QoS1_Pub_______0b_Payload-8 5 2 -60.00% BenchmarkMQTT_QoS1_Pub_______8b_Payload-8 5 2 -60.00% BenchmarkMQTT_QoS1_Pub______32b_Payload-8 5 2 -60.00% BenchmarkMQTT_QoS1_Pub_____128b_Payload-8 7 3 -57.14% BenchmarkMQTT_QoS1_Pub_____256b_Payload-8 7 3 -57.14% BenchmarkMQTT_QoS1_Pub_______1K_Payload-8 7 3 -57.14% benchmark old bytes new bytes delta BenchmarkMQTT_QoS0_Pub_______0b_Payload-8 80 0 -100.00% BenchmarkMQTT_QoS0_Pub_______8b_Payload-8 88 0 -100.00% BenchmarkMQTT_QoS0_Pub______32b_Payload-8 120 0 -100.00% BenchmarkMQTT_QoS0_Pub_____128b_Payload-8 224 0 -100.00% BenchmarkMQTT_QoS0_Pub_____256b_Payload-8 369 1 -99.73% BenchmarkMQTT_QoS0_Pub_______1K_Payload-8 1250 31 -97.52% BenchmarkMQTT_QoS1_Pub_______0b_Payload-8 106 28 -73.58% BenchmarkMQTT_QoS1_Pub_______8b_Payload-8 122 28 -77.05% BenchmarkMQTT_QoS1_Pub______32b_Payload-8 154 28 -81.82% BenchmarkMQTT_QoS1_Pub_____128b_Payload-8 381 157 -58.79% BenchmarkMQTT_QoS1_Pub_____256b_Payload-8 655 287 -56.18% BenchmarkMQTT_QoS1_Pub_______1K_Payload-8 2312 1078 -53.37% ``` Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
NATS is a simple, secure and performant communications system for digital systems, services and devices. NATS is part of the Cloud Native Computing Foundation (CNCF). NATS has over 40 client language implementations, and its server can run on-premise, in the cloud, at the edge, and even on a Raspberry Pi. NATS can secure and simplify design and operation of modern distributed systems.
Documentation
- Official documentation
- FAQ
- Watch a video overview of NATS to learn more about its origin story and design philosophy.
Contact
- Twitter: Follow us on Twitter!
- Google Groups: Where you can ask questions
- Slack: Click here to join. You can ask question to our maintainers and to the rich and active community.
Contributing
If you are interested in contributing to NATS, read about our...
Security
Security Audit
A third party security audit was performed by Cure53, you can see the full report here.
Reporting Security Vulnerabilities
If you've found a vulnerability or a potential vulnerability in the NATS server, please let us know at nats-security.
License
Unless otherwise noted, the NATS source files are distributed under the Apache Version 2.0 license found in the LICENSE file.
