Skip to content

Conversation

@dorjesinpo
Copy link
Collaborator

  1. Introducing bmqp::MessageProperties ::d_doDeepCopy (true by default). When false , there is no blob copy. Meaning, MessageProperties valid only when the original blob is alive. This helps Routers::MessagePropertiesReader when iterating subscriptions.

  2. avoiding extra bsl::string copy when reading strings from blob. Use bsl::string_view instead. Note that setProperty still needs to copy strings. And getProperty needs to convert bsl::string_view into bsl::string. Again, Routers::MessagePropertiesReader does benefit from the use of bsl::string_view.

@dorjesinpo dorjesinpo requested a review from a team as a code owner November 7, 2025 00:40
@dorjesinpo dorjesinpo added the enhancement New feature or request label Nov 7, 2025
Copy link

@bmq-oss-ci bmq-oss-ci bot left a comment

Choose a reason for hiding this comment

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

Build 3106 of commit f06a195 has completed with FAILURE

@dorjesinpo dorjesinpo changed the title minimizing copies minimizing copies in MessageProperties Nov 7, 2025
@678098 678098 assigned 678098 and dorjesinpo and unassigned 678098 Nov 14, 2025
Signed-off-by: dorjesinpo <[email protected]>
Signed-off-by: dorjesinpo <[email protected]>
@678098 678098 changed the title minimizing copies in MessageProperties Perf[BMQP]: minimizing copies in MessageProperties Nov 14, 2025
if (ret == 0) {
// Do not align
if (position.buffer() == end.buffer() ||
(position.buffer() + 1 == end.buffer() && end.byte() == 0)) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it's worth extracting this to bmqu::BlobUtil::isDataContinuous(start, end)

doCopy = false;
}
}
if (doCopy) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

We can still get rid of doCopy if we just return when we read a property

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sure, but is it that much better?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's keep the current one

Copy link
Collaborator

Choose a reason for hiding this comment

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

Without micro-benchmarks we can only speculate if it is better or not


const PropertyVariant& value = getPropertyValueAsString(it->second);

BSLS_ASSERT(value.is<bsl::string>() && "Property data type mismatch");
Copy link
Collaborator

Choose a reason for hiding this comment

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

There was just 1 call in this function before, now there are at least 2 calls and 2 extra checks. Not sure if it doesn't harm the performance more than the benefit we get from this PR.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

There were the same calls findProperty and getPropertyValue (in getProperty).
The same check.
What is added is this:

    if (v.is<bsl::string_view>()) {
        v = bsl::string(v.the<bsl::string_view>(), d_allocator_p);
    }

Consider the fact that MessagePropertiesReader does not make a copy of string anymore (it does not execute this code). That is one of main benefits of this PR. The second one being not copying blob.

Copy link

@bmq-oss-ci bmq-oss-ci bot left a comment

Choose a reason for hiding this comment

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

Build 3137 of commit f0bee45 has completed with FAILURE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants