Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for ReadOnlySequence as payload #2046

Merged
merged 8 commits into from
Jul 24, 2024

Conversation

mregen
Copy link
Contributor

@mregen mregen commented Jul 14, 2024

Support ReadOnlySequence as a payload in the MQTTnet client, for the new version5 release.

The MQTTNet write method only accepts an ArraySegment which is a view into a single buffer. It is currently necessary to call ToArray to support a RecyclableMemoryStream.
As a result, perfomance is affected by additional copies and memory is fragment by the additional random allocation of large buffers.

This is a minimal version without lifetime management in the receive code path to get started.
Since the publish codepath can manage the lifetime of the buffers externally, all publishing applications can already benefit from the implementation.
To minimize the impact on existing code the PayloadSegment setter is kept to convert an ArraySegment to a ReadOnlySequence implicitly, allowing most of the tests to compile unchanged.

Added also a few tests to show how to use a RecyclableMemoryStream.

see #1917 and #1918 with the issue explained.

@mregen
Copy link
Contributor Author

mregen commented Jul 15, 2024

Hi @chkr1011, thanks for the code review!
Once merged, with a signed preview package I can start testing version5 in our various projects and end 2 end tests.
Cheers, Martin

@chkr1011 chkr1011 merged commit 1830364 into dotnet:version5 Jul 24, 2024
5 of 6 checks passed
chkr1011 added a commit that referenced this pull request Aug 24, 2024
* Remove WebSocket4Net extension library

* Remove UWP support

* Drop support for all old frameworks

* Update CI

* Update CI

* Update CI

* Update CI

* Remove obsolete code

* Set default protocol version to 5.0.0

* Remove obsolete tests

* Remove old dependencies

* Reset release notes

* Move server to dedicated project

* Fix unit tests

* Update and cleanup nuget packages

* Fix unit tests
Refactor code

* No longer throw exception when receiving non success CONNACK

* Enable nuget signing

* Enable nuget signing

* Enable nuget signing

* Enable nuget signing

* Enable nuget signing

* Enable nuget signing

* Enable nuget signing

* Enable nuget signing

* Enable code signing

* Enable code signing

* Enable code signing

* Fix client endpoint handling

* Improve CI

* Fix CI

* Fix CI

* Fix CI

* Fix CI

* Import changes from version 4

* Cleanup target frameworks and remove obsolete code

* Drop support for dotnet7.0

* Remove managed client

* Version5 auditmode (#2016)

Added NuGet audit mode and some other settings to get informed about security issues.

* Address warnings from analyzers

* Support for ReadOnlySequence as payload (#2046)

* use ReadOnlySequence as payload

* fix build

* fix build

* skip sign in forks

* remove unnecessary owner

* tests and extensions

* remove test

* simplify WritePacketBuffer, remove unused helper

* Adjust namespaces

* Fix build errors

* Import latest fixes from main branch

* Adjust namespaces

---------

Co-authored-by: SeppPenner <[email protected]>
Co-authored-by: Martin Regen <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants