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

[RF] Make RooProdPdf::_pdfNSetList a std::vector and not RooLinkedList #8595

Merged
merged 1 commit into from
Jan 19, 2022

Conversation

guitargeek
Copy link
Contributor

Part of the RooProdPdf modernization with the intention of eventually
deprecating the RooLinkedList.

This change reduces the size of a RooProdPdf from 1600 to 1496 bytes.

A manual schema evolution rule to test the reading of older RooProdPdfs
is implemented in the LinkDef.h. The schma evolution is tested by
the stressRooFit tests, which are reading some RooProdPdfs from the
reference files.

Comment on lines 253 to 258
#pragma read sourceClass="RooProdPdf" targetClass="RooProdPdf" version="[4]" \
source="RooLinkedList _pdfNSetList" target="_pdfNSetList" \
code="{RooFIter iter = onfile._pdfNSetList.fwdIterator(); \
while(auto nset = (RooArgSet*)iter.next()) { \
_pdfNSetList.emplace_back(*nset); \
} \
}";
Copy link
Member

Choose a reason for hiding this comment

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

This could potentially leak. It's worth checking at least: You're creating a copy of the objects pointed to by the linked list. When the I/O operation is finished, the original objects are still around, and I'm not sure that anybody owns them. I hope that the linked list does, and will delete them once everything is deserialised, but I'm not sure.

At the same time, you cannot destroy them here in this loop, since they might be (co-)owned by another entity in the same file. Did you check what happens?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Very good point, thanks for noticing! I solved this problem now by avoiding the copy. The RooLinkedList is now replaced with a std::vector<std::unique_ptr<RooArgSet>> instead of a std::vector<RooArgSet>. So the RooArgSet is not copied anymore, the ownership is only transferred from the RooLinkedList to the unique_ptr.

Fortunately we don't need to worry about co-owning, because as you also noticed from the RooProdPdf constructor the RooProdPdf object is responsible to call Delete() on the list.

Copy link
Member

Choose a reason for hiding this comment

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

I think this is doing the right thing now. I don't think it's the case (since the member is private), but just be aware that there might be a file somewhere in the world where two objects see those pointers. Since you don't touch the pointer during the I/O operation, they will still have "shared ownership" after the I/O operation completes, but from then, the ProdPdf owns exclusively (via the unique_ptr), while the other object just observes.

That's probably all fine, because people observing the internal norm sets are asking for trouble. You could only achieve this via friend classes or other evil things.

@@ -439,7 +431,6 @@ void RooProdPdf::initializeFromCmdArgList(const RooArgSet& fullPdfSet, const Roo

RooProdPdf::~RooProdPdf()
{
_pdfNSetList.Delete() ;
Copy link
Member

Choose a reason for hiding this comment

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

This is the indication that the list on disc doesn't own the objects ...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, that's a good hint!

@root-project root-project deleted a comment from phsft-bot Jan 19, 2022
@root-project root-project deleted a comment from phsft-bot Jan 19, 2022
@root-project root-project deleted a comment from phsft-bot Jan 19, 2022
@root-project root-project deleted a comment from phsft-bot Jan 19, 2022
@root-project root-project deleted a comment from phsft-bot Jan 19, 2022
@root-project root-project deleted a comment from phsft-bot Jan 19, 2022
@root-project root-project deleted a comment from phsft-bot Jan 19, 2022
@root-project root-project deleted a comment from phsft-bot Jan 19, 2022
@root-project root-project deleted a comment from phsft-bot Jan 19, 2022
@root-project root-project deleted a comment from phsft-bot Jan 19, 2022
@guitargeek guitargeek force-pushed the RooProdPdf_1 branch 2 times, most recently from c3a8a00 to acab81d Compare January 19, 2022 10:51
@phsft-bot
Copy link
Collaborator

Starting build on ROOT-debian10-i386/cxx14, ROOT-performance-centos8-multicore/default, ROOT-ubuntu16/nortcxxmod, ROOT-ubuntu2004/soversion, mac1015/python3, mac11/cxx17, windows10/cxx14
How to customize builds

@root-project root-project deleted a comment from phsft-bot Jan 19, 2022
@phsft-bot
Copy link
Collaborator

Build failed on mac11/cxx17.
See console output.

Part of the RooProdPdf modernization with the intention of eventually
deprecating the RooLinkedList.

This change reduces the size of a RooProdPdf from 1600 to 1496 bytes.

A manual schema evolution rule to test the reading of older RooProdPdfs
is implemented in the `LinkDef.h`. The schma evolution is tested by
the stressRooFit tests, which are reading some RooProdPdfs from the
reference files.
@phsft-bot
Copy link
Collaborator

Starting build on ROOT-debian10-i386/cxx14, ROOT-performance-centos8-multicore/default, ROOT-ubuntu16/nortcxxmod, ROOT-ubuntu2004/soversion, mac1015/python3, mac11/cxx17, windows10/cxx14
How to customize builds

@phsft-bot
Copy link
Collaborator

Build failed on mac11/cxx17.
See console output.

Copy link
Member

@hageboeck hageboeck left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@lmoneta lmoneta left a comment

Choose a reason for hiding this comment

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

Nice improvement worth having in the master and in the next release!

@guitargeek guitargeek merged commit 5244b24 into root-project:master Jan 19, 2022
@guitargeek guitargeek deleted the RooProdPdf_1 branch January 19, 2022 15:42
@phsft-bot
Copy link
Collaborator

Build failed on ROOT-ubuntu2004/soversion.
Running on root-ubuntu-2004-3.cern.ch:/home/sftnight/build/workspace/root-pullrequests-build
See console output.

Errors:

  • [2022-01-19T16:12:30.868Z] CMake Error at /home/sftnight/build/workspace/root-pullrequests-build/rootspi/jenkins/root-build.cmake:1064 (message):

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

Successfully merging this pull request may close these issues.

4 participants