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
Removed usage of DDVectorGetter from production code #30069
Conversation
The DDVectorGetter was using a thread-unsafe singleton. The relevant information can be obtained directly from the DDCompactView or Views derived from it. This matches what is being done in the dd4hep migration.
The code-checks are being triggered in jenkins. |
+code-checks Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-30069/15795
|
A new Pull Request was created by @Dr15Jones (Chris Jones) for master. It involves the following packages: DetectorDescription/Core @civanch, @Dr15Jones, @makortel, @cvuosalo, @ianna, @mdhildreth, @cmsbuild, @kpedro88 can you please review it and eventually sign? Thanks. cms-bot commands are listed here |
please test |
The tests are being triggered in jenkins. |
const std::vector<double>& DDCompactView::vector(std::string_view iKey) const { | ||
auto itFind = vectors_.find(std::string(iKey)); |
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.
Just curious, why not
const std::vector<double>& DDCompactView::vector(std::string_view iKey) const { | |
auto itFind = vectors_.find(std::string(iKey)); | |
const std::vector<double>& DDCompactView::vector(std::string const& iKey) const { | |
auto itFind = vectors_.find(iKey); |
?
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 was hoping in C++20 I could drop the string copy :)
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.
Thanks, sounds good.
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.
See https://en.cppreference.com/w/cpp/container/map/find which shows in C++14 they added the ability to do a find without having to create a key. Not sure why it didn't work here :(.
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.
https://stackoverflow.com/questions/35525777/use-of-string-view-for-map-lookup
seems to imply it might not be work it :(
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.
oh, yes... I've added the lockdown
as well :-)
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.
after the parsing is done
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.
In the code snippet above, where did you get vnames
?
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.
@@ -59,12 +59,15 @@ int main(int argc, char* argv[]) {
DDErrorDetection ed(cpv);
ed.report(cpv, std::cout);
+ cpv.lockdown();
DDConstant::iterator<DDConstant> cit(DDConstant::begin()), ced(DDConstant::end());
for (; cit != ced; ++cit) {
cout << *cit << endl;
}
+ std::vector<std::string> vnames;
+
DDVector::iterator<DDVector> vit;
DDVector::iterator<DDVector> ved(DDVector::end());
if (vit == ved)
@@ -72,6 +75,7 @@ int main(int argc, char* argv[]) {
for (; vit != ved; ++vit) {
if (vit->isDefined().second) {
std::cout << vit->toString() << std::endl;
+ vnames.emplace_back(DDName(vit->name()).name());
const std::vector<double>& tv = *vit;
std::cout << "size: " << tv.size() << std::endl;
for (double i : tv) {
@@ -80,12 +84,21 @@ int main(int argc, char* argv[]) {
std::cout << std::endl;
}
}
-
- std::vector<string> vnames;
- DDVectorGetter::beginWith("Subdetector", vnames);
- for (std::vector<string>::const_iterator sit = vnames.begin(); sit != vnames.end(); ++sit) {
- std::cout << sit->c_str() << std::endl;
+ for(const auto& it : vnames) {
+ std::cout << it << std::endl;
+ auto v = cpv.vector(it);
+ std::cout << "size: " << v.size() << std::endl;
+ for (double i : v) {
+ std::cout << i << "\t";
+ }
+ std::cout << std::endl;
}
+
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 should stop writing code before getting a response for stuff I ask others how they did it :)]
@Dr15Jones This PR is worrisome. It is changing core old-DD functionality at the same time as we are migrating to DD4hep and trying to validate against the old DD. If it is bug-free and perfect, that would be fine, but any hidden errors would be a bothersome diversion while we are trying to focus on DD4hep. |
The thread-safety changes are finishing up testing now and could be ready to deploy this week. They need to be tested well before Run 3 and are best to add early in the CMSSW_11_2 cycle. |
This change should also be bit-wise-identical to what we have now. If not, there is a problem with this code. |
+1 The following merge commits were also included on top of IB + this PR after doing git cms-merge-topic:
You can see more details here: |
Comparison job queued. |
Comparison is ready Comparison Summary:
|
@Dr15Jones - nicely done! I'd suggest to remove the |
for (std::vector<string>::const_iterator sit = vnames.begin(); sit != vnames.end(); ++sit) { | ||
std::cout << sit->c_str() << std::endl; | ||
//This forces the 'vector' to be filled | ||
cpv.lockdown(); |
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.
@ianna I did the lockdown
here rather than right after the parsing in the case that we decide to clear the DDVector
container in that call since such a clear would break the loop just before this one.
+code-checks Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-30069/15810
|
Pull request #30069 was updated. @civanch, @Dr15Jones, @makortel, @cvuosalo, @ianna, @mdhildreth, @cmsbuild, @kpedro88 can you please check and sign again. |
please test |
The tests are being triggered in jenkins. |
+1 |
Comparison job queued. |
Comparison is ready Comparison Summary:
|
+1 |
+upgrade |
This pull request is fully signed and it will be integrated in one of the next master IBs (tests are also fine). This pull request will now be reviewed by the release team before it's merged. @silviodonato, @dpiparo (and backports should be raised in the release meeting by the corresponding L2) |
+1 |
PR description:
The DDVectorGetter was using a thread-unsafe singleton. The relevant information can be obtained directly from the DDCompactView or Views derived from it. This matches what is being done in the dd4hep migration.
This is needed to support concurrent EventSetup module running (and we've just been lucky it hasn't hurt us up to this point).
PR validation:
The code compiles. I don't know how to test this. The change should be strictly technical with not change in behavior.