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

Avoid copying of MqttPublishMessage.payload byte buffer #13939

Open
wants to merge 2 commits into
base: 4.1
Choose a base branch
from

Conversation

Munoon
Copy link

@Munoon Munoon commented Mar 29, 2024

Motivation:
MqttMessageBuilders make unnecessary copies of Publish message payload,which takes up extra CPU and memory.
Most user cases allow avoiding this.

Modification:
Remove payload copying in MqttMessageBuilders.PublishBuilder and duplicating in MqttEncoder.

Result:
Less CPU and memory usage.

Fixes #13844

@@ -453,6 +453,7 @@ private static ByteBuf encodePublishMessage(
return buf;
} finally {
propertiesBuf.release();
payload.release();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will need to check in details but if this is needed here it was also needed in the original code

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, there is a back comparability issue. Maybe you have some ideas to avoid it?

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.

Mqtt payload for publish message copied 2 times during lifetime
2 participants