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

Add ByteString ToReadOnlySpan #7487

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

fmg-lydonchandra
Copy link

@fmg-lydonchandra fmg-lydonchandra commented Jan 24, 2025

Fixes #

Changes

Add ByteString ToReadOnlySpan, which has NO memory copy, compared to ToArray(), when ByteString is compact.

Why?

Currently we do a lot of RabbitMQ IncomingMessage Deserialization by calling ToArray() (which does memory copying)

        var evt = JsonSerializer.Deserialize<T>(message.Message.Bytes.ToArray(), SerializerOptions);

Using ToReadOnlySpan, memory copy can be avoided, as most of our IncomingMessage is compact

Checklist

For significant changes, please ensure that the following have been completed (delete if not relevant):

Latest dev Benchmarks

Include data from the relevant benchmark prior to this change here.

This PR's Benchmarks

Include data from after this change here.

@fmg-lydonchandra
Copy link
Author

Hi, is this change worth having? if so, will add tests.

@Aaronontheweb
Copy link
Member

Hi, is this change worth having? if so, will add tests.

LGTM - please add some tests

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