-
Notifications
You must be signed in to change notification settings - Fork 155
Perf[BMQP]: minimizing copies in MessageProperties #1014
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
base: main
Are you sure you want to change the base?
Conversation
d8af6aa to
f06a195
Compare
There was a problem hiding this 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
f06a195 to
1ada41f
Compare
Signed-off-by: dorjesinpo <[email protected]>
Signed-off-by: dorjesinpo <[email protected]>
1ada41f to
f0bee45
Compare
| if (ret == 0) { | ||
| // Do not align | ||
| if (position.buffer() == end.buffer() || | ||
| (position.buffer() + 1 == end.buffer() && end.byte() == 0)) { |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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"); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this 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
Introducing
bmqp::MessageProperties ::d_doDeepCopy(trueby default). Whenfalse, there is noblobcopy. Meaning,MessagePropertiesvalid only when the originalblobis alive. This helpsRouters::MessagePropertiesReaderwhen iterating subscriptions.avoiding extra
bsl::stringcopy when reading strings from blob. Usebsl::string_viewinstead. Note thatsetPropertystill needs to copy strings. AndgetPropertyneeds to convertbsl::string_viewintobsl::string. Again,Routers::MessagePropertiesReaderdoes benefit from the use ofbsl::string_view.