From b84f023d3cc44953d0fedda3b9f4af153a006d1b Mon Sep 17 00:00:00 2001 From: Peter Giacomo Lombardo Date: Thu, 25 Jul 2024 10:53:20 +0200 Subject: [PATCH 1/3] Add AutomaticReconnect, links and see also --- Documentation/docs/connecting.md | 45 +++++++++----------------------- 1 file changed, 12 insertions(+), 33 deletions(-) diff --git a/Documentation/docs/connecting.md b/Documentation/docs/connecting.md index 5715a14e..4b6bf0be 100644 --- a/Documentation/docs/connecting.md +++ b/Documentation/docs/connecting.md @@ -18,7 +18,7 @@ var client = new HiveMQClient(); var connectResult = await client.ConnectAsync().ConfigureAwait(false); ``` -## With Options +## With Specific Options The `HiveMQClientOptions` class provides a set of options that can be used to configure various aspects of the `HiveMQClient`. @@ -35,44 +35,23 @@ var client = new HiveMQClient(options); var connectResult = await client.ConnectAsync().ConfigureAwait(false); ``` -## `HiveMQClientOptionsBuilder` Reference - -To illustrate _each and every possible call_ with `HiveMQClientOptionsBuilder`, see the following example: +## With Automatic Reconnect ```csharp -using HiveMQtt.MQTT5.Types; // For QualityOfService enum - -var options = new HiveMQClientOptionsBuilder() - .WithBroker("broker.hivemq.com") - .WithPort(1883) - .WithClientId("myClientId") - .WithAllowInvalidBrokerCertificates(true) - .WithUseTls(true) - .WithCleanStart(true) - .WithKeepAlive(60) - .WithAuthenticationMethod("UsernamePassword") - .WithAuthenticationData(Encoding.UTF8.GetBytes("authenticationData")) - .WithUserProperty("property1", "value1") - .WithUserProperties(new Dictionary { { "property1", "value1" }, { "property2", "value2" } }) - .WithLastWill(new LastWillAndTestament { - Topic = "lwt/topic", - PayloadAsString = "LWT message", - QoS = QualityOfService.AtLeastOnceDelivery, - Retain = true }) - .WithMaximumPacketSize(1024) - .WithReceiveMaximum(100) - .WithSessionExpiryInterval(3600) - .WithUserName("myUserName") - .WithPassword("myPassword") - .WithPreferIPv6(true) - .WithTopicAliasMaximum(10) - .WithRequestProblemInformation(true) - .WithRequestResponseInformation(true) - .Build(); +var options = new HiveMQClientOptionsBuilder(). + WithBroker('candy.x39.eu.hivemq.cloud'). + WithAutomaticReconnect(true) + Build(); + +var client = new HiveMQClient(options); +var connectResult = await client.ConnectAsync().ConfigureAwait(false); ``` + ## See Also +* [HiveMQClientOptionsBuilder Reference](/docs/reference/client_options_builder) +* [Automatic Reconnect](/docs/reference/automatic_reconnect) * [How to Set a Last Will & Testament](/docs/how-to/set-lwt) * [Connect with TLS but allow Invalid TLS Certificates](/docs/how-to/allow-invalid-certs) * [Securely Connect to a Broker with Basic Authentication Credentials](/docs/how-to/connect-with-auth) From 7d01d2ce84acbe7f84eba505d0a5f8d30e2f0c75 Mon Sep 17 00:00:00 2001 From: Peter Giacomo Lombardo Date: Thu, 25 Jul 2024 11:46:10 +0200 Subject: [PATCH 2/3] Updated benchmark results --- Documentation/docs/benchmarks.md | 71 ++++++++++++++++++++++++++++---- 1 file changed, 62 insertions(+), 9 deletions(-) diff --git a/Documentation/docs/benchmarks.md b/Documentation/docs/benchmarks.md index 80b8dae5..905c594a 100644 --- a/Documentation/docs/benchmarks.md +++ b/Documentation/docs/benchmarks.md @@ -21,14 +21,57 @@ The benchmarks provide insights into the performance of different messaging meth ## Legend -``` - Mean : Arithmetic mean of all measurements - Error : Half of 99.9% confidence interval - StdDev : Standard deviation of all measurements - Median : Value separating the higher half of all measurements (50th percentile) - 1 us : 1 Microsecond (0.000001 sec) - 1 ms : 1,000 Microseconds -``` +* **Mean**: Arithmetic mean of all measurements +* **Error**: Half of 99.9% confidence interval +* **StdDev**: Standard deviation of all measurements +* **Median**: Value separating the higher half of all measurements (50th percentile) +* **1 us**: 1 Microsecond (0.000001 sec) +* **1 ms**: 1,000 Microseconds +* Green: Improvement +* Red: Regression + +## July 25, 2024 + +### Summary + +The client has had many feature additions and improvements from March 2024 including: + +* New Back-pressure support +* Improved QoS reliability +* Improved Async await strategies +* Re-architected internal queues +* Improved event & trigger handling +* All around better error handling + +The following table shows the benchmark results compared against previous benchmark runs. + +| Method | Alpha | March 2024 | July 2024 | +| ------ | ----- | -------- | -------------- | +| QoS 0 Message | 4.875 us | 9.084 us | 5.500 us | +| QoS 1 Message | 790.645 us | 1,357.063 us | 982.208 us | +| QoS 2 Message | 1,653.083 us | 1,292.396 us | 1,004.854 us | +| 100 QoS 0 @ 256b | No Data | 79.604 us | 100.375 us | +| 100 QoS 1 @ 256b | No Data | 42,482.520 us | 29,661.605 us | +| 100 QoS 2 @ 256b | No Data | 85,640.167 us | 55,474.250 us | +| 100 QoS 0 @ 256k | No Data | 69.709 us | 99.354 us | +| 100 QoS 1 @ 256k | No Data | 266,506.583 us | 215,158.104 us | +| 100 QoS 2 @ 256k | No Data | 296,254.688 us | 227,255.729 us | + +### July Benchmark Data + +The raw benchmark data from July. + +| Method | Mean | Error | StdDev | Median | +|------------------------------------------------- |--------------:|-------------:|--------------:|---------------:| +| 'Publish a QoS 0 message' | 32.59 us | 85.64 us | 252.53 us | 5.500 us | +| 'Publish a QoS 1 message' | 6,323.30 us | 16,671.57 us | 49,156.51 us | 982.208 us | +| 'Publish a QoS 2 message' | 6,554.90 us | 16,998.38 us | 50,120.10 us | 1,004.854 us | +| 'Publish 100 256b length payload QoS 0 messages' | 131.73 us | 92.15 us | 271.71 us | 100.375 us | +| 'Publish 100 256b length payload QoS 1 messages' | 35,405.71 us | 17,183.26 us | 50,665.23 us | 29,661.605 us | +| 'Publish 100 256b length payload QoS 2 messages' | 61,955.04 us | 17,559.19 us | 51,773.66 us | 55,474.250 us | +| 'Publish 100 256k length payload QoS 0 messages' | 129.00 us | 83.24 us | 245.42 us | 99.354 us | +| 'Publish 100 256k length payload QoS 1 messages' | 226,498.28 us | 42,050.59 us | 123,987.13 us | 215,158.104 us | +| 'Publish 100 256k length payload QoS 2 messages' | 244,227.03 us | 47,932.40 us | 141,329.77 us | 227,255.729 us | ## Mar 22, 2024 @@ -50,7 +93,17 @@ See also: [What is MQTT Quality of Service (QoS) 0,1, & 2? – MQTT Essentials: ## Mar 21, 2024 -With release [v0.11.0](https://github.com/hivemq/hivemq-mqtt-client-dotnet/releases/tag/v0.11.0) there was a big performance improvement. All messaging performance was improved but particularly publishing a QoS level 2 message went from ~206ms down to ~1.6ms. +With release [v0.11.0](https://github.com/hivemq/hivemq-mqtt-client-dotnet/releases/tag/v0.11.0) there was a big performance improvement. All messaging performance was improved but particularly publishing a **QoS level 2 message went from ~206ms down to ~1.6ms**. + +### Summary + +From the early version through two refactors, this table summarizes the performance improvements. + +| Method | Original | First Pass Refactor | Final Refactor | +| ------ | -------- | ------------------- | -------------- | +| QoS 0 Message | 5.646 us | 9.250 us | 4.875 us | +| QoS 1 Message | 103,536.375 us | 1,324.251 us | 790.645 us | +| QoS 2 Message | 206,959.834 us | 2,569.166 us | 1,653.083 us | ### Previous Performance From 2a4b3a9ca2856235ab88b1a55ff721553d323fd9 Mon Sep 17 00:00:00 2001 From: Peter Giacomo Lombardo Date: Thu, 25 Jul 2024 11:52:34 +0200 Subject: [PATCH 3/3] language fixups --- Documentation/docs/benchmarks.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Documentation/docs/benchmarks.md b/Documentation/docs/benchmarks.md index 905c594a..aebe4ec2 100644 --- a/Documentation/docs/benchmarks.md +++ b/Documentation/docs/benchmarks.md @@ -4,7 +4,9 @@ sidebar_position: 90 # Benchmarks -The benchmarks provided in the HiveMQtt GitHub repository are built using BenchmarkDotNet, a .NET library for benchmarking. These benchmarks are designed to measure the performance of various messaging operations against any MQTT broker. +The HiveMQtt GitHub repository provides benchmarks built using BenchmarkDotNet, a .NET library for benchmarking. These benchmarks measure the performance of various messaging operations against any MQTT broker. + + ## Running Benchmarks @@ -17,7 +19,7 @@ dotnet run ClientBenchmarkApp.csproj -c Release ## Results -The benchmarks provide insights into the performance of different messaging methods under various scenarios. Below are the results obtained from running the benchmarks on a local MBP (MacBook Pro) against a HiveMQ v4 broker running in a Docker container over localhost. +The benchmarks provide insights into the performance of different messaging methods under various scenarios. Below are the results obtained from running the benchmarks on a local MacBook Pro against a HiveMQ v4 broker running in a Docker container over localhost. ## Legend