mgr, mon, osdc: pass complex parameters by rvalue reference#65014
mgr, mon, osdc: pass complex parameters by rvalue reference#65014MaxKellermann merged 1 commit intoceph:mainfrom
Conversation
|
jenkins test make check arm64 |
1 similar comment
|
jenkins test make check arm64 |
|
arm64 keeps crashing with SIGBUS, but I don't think that's related.... so I keep repeating the test run! Sigh. |
|
jenkins test make check arm64 |
1 similar comment
|
jenkins test make check arm64 |
That strategy has worked, yet again. |
|
This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved |
070663f to
3c4512f
Compare
src/common/mclock_common.cc
Outdated
| dout(10) << __func__ << " Removing Key: " << *key | ||
| << " for " << osd << " from Mon db" << dendl; | ||
| monc->start_mon_command(vcmd, {}, nullptr, nullptr, nullptr); | ||
| monc->start_mon_command({std::move(cmd)}, {}, nullptr, nullptr, nullptr); |
There was a problem hiding this comment.
Aren't you changing more than the value category here (i.e. by moving from a vector to a single string)?
There was a problem hiding this comment.
I don't understand. What do you think is changed here? What is a "value category"?
There was a problem hiding this comment.
(value category: lvalue, rvalue, etc.)
I was ref'ing the change that replaced the vector of strings with one string (which seemed to be unrelated)
There was a problem hiding this comment.
And - a general question: as you are changing some 'const A&' to 'A&': did you run a static analyzer to verify that no 'use after move' instances were created?
There was a problem hiding this comment.
that replaced the vector of strings with one string (which seemed to be unrelated)
I did not replace a vector or strings with one string. Maybe you missed the curly braces?
There was a problem hiding this comment.
And - a general question: as you are changing some 'const A&' to 'A&': did you run a static analyzer to verify that no 'use after move' instances were created?
No, I don't have a static analyzer. But I did not change const A& to A&, but const A& to A&&.
There was a problem hiding this comment.
No, I don't have a static analyzer. But I did not change
const A&toA&, butconst A&toA&&.
Sure - that's what I meant. Sorry. The question is this: the original signature of a function such as that had guaranteed that the argument won't be changed. Now - it was moved-from. Are you sure there are no cases where the client did use the argument? I tried to follow some of the cases, but a static analyzer is better at that.
There was a problem hiding this comment.
I did not replace a vector or strings with one string. Maybe you missed the curly braces?
Yes - I did miss that, but now I wonder what will happen there. Going to check.
There was a problem hiding this comment.
Are you sure there are no cases where the client did use the argument?
I checked all changes (by code review, not by running them - I don't have any Ceph installation that I can use to test this), and I'm confident that they are correct. Minus human mistakes, as always.
There was a problem hiding this comment.
(I assume you have this working, but - if you need help running a vstart configuration - let me know)
|
a final comment for now: as it is now, this PR spans 3 teams, which might make its approval into a lengthy process. |
Everything with Ceph is a lengthy process! At the current rate, it will take a decade or two until all my finished patches are merged. I have hundreds on my stgit stack, only waiting for dependent PRs to get merged. |
|
This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved |
|
Thanks @anrao19 - there are now conflicts with newly merged commits. I can rebase & force-push - do you want me to? |
Yes, please. |
|
@ljflores Would you be willing to have someone schedule RADOS QA? |
5203141 to
e3cbd0a
Compare
done |
|
This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved |
e3cbd0a to
419231b
Compare
|
Rebased again to fix conflict with newly merged PRs. |
|
jenkins test make check arm64 |
|
This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved |
A non-trivial type is always passed by reference, even if the parameter is declared as a value; in that case, the compiler must allocate stack space and move the value there, and then really passes a reference to this stack allocation. This only adds overhead for no reason. A side effect of this API change is that all callers that accidently created temporary copies are now revealed by throwing a compiler error. This commit fixes all callers and reduces a good amount of useless overhead by wrapping those parameters in std::move() instead of copying temporaries. More temporaries are avoided by emplacing the std::string&& into the std::vector. Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
419231b to
f82ab1c
Compare
|
RGW PR testing completed and approved by @ivancich. Details : https://tracker.ceph.com/issues/73623 |
… rvalue refs PR ceph#65014 added std::move() inside the while loop, which required recreating the command string on each iteration. Add const std::string& overload that forwards to the existing std::string&& version, allowing the command to be declared outside the loop for better efficiency. Fixes: https://tracker.ceph.com/issues/73838 Signed-off-by: Nitzan Mordechai <nmordech@ibm.com>
… rvalue refs PR ceph#65014 added std::move() inside the while loop, which required recreating the command string on each iteration. Add const std::string& overload that forwards to the existing std::string&& version, allowing the command to be declared outside the loop for better efficiency. Fixes: https://tracker.ceph.com/issues/73838 Signed-off-by: Nitzan Mordechai <nmordech@ibm.com>
… rvalue refs PR ceph#65014 added std::move() inside the while loop, which required recreating the command string on each iteration. Add const std::string& overload that forwards to the existing std::string&& version, allowing the command to be declared outside the loop for better efficiency. Fixes: https://tracker.ceph.com/issues/73838 Signed-off-by: Nitzan Mordechai <nmordech@ibm.com> (cherry picked from commit 3e107ec)
… rvalue refs PR ceph#65014 added std::move() inside the while loop, which required recreating the command string on each iteration. Add const std::string& overload that forwards to the existing std::string&& version, allowing the command to be declared outside the loop for better efficiency. Fixes: https://tracker.ceph.com/issues/73838 Signed-off-by: Nitzan Mordechai <nmordech@ibm.com>
… rvalue refs PR ceph#65014 added std::move() inside the while loop, which required recreating the command string on each iteration. Add const std::string& overload that forwards to the existing std::string&& version, allowing the command to be declared outside the loop for better efficiency. Fixes: https://tracker.ceph.com/issues/73838 Signed-off-by: Nitzan Mordechai <nmordech@ibm.com>
A non-trivial type is always passed by reference, even if the parameter is declared as a value; in that case, the compiler must allocate stack space and move the value there, and then really passes a reference to this stack allocation. This only adds overhead for no reason.
A side effect of this API change is that all callers that accidently created temporary copies are now revealed by throwing a compiler error. This commit fixes all callers and reduces a good amount of useless overhead by wrapping those parameters in std::move() instead of copying temporaries.
More temporaries are avoided by emplacing the std::string&& into the std::vector.
Checklist
Show available Jenkins commands
jenkins test classic perfJenkins Job | Jenkins Job Definitionjenkins test crimson perfJenkins Job | Jenkins Job Definitionjenkins test signedJenkins Job | Jenkins Job Definitionjenkins test make checkJenkins Job | Jenkins Job Definitionjenkins test make check arm64Jenkins Job | Jenkins Job Definitionjenkins test submodulesJenkins Job | Jenkins Job Definitionjenkins test dashboardJenkins Job | Jenkins Job Definitionjenkins test dashboard cephadmJenkins Job | Jenkins Job Definitionjenkins test apiJenkins Job | Jenkins Job Definitionjenkins test docsReadTheDocs | Github Workflow Definitionjenkins test ceph-volume allJenkins Jobs | Jenkins Jobs Definitionjenkins test windowsJenkins Job | Jenkins Job Definitionjenkins test rook e2eJenkins Job | Jenkins Job Definition