-
Notifications
You must be signed in to change notification settings - Fork 1.4k
[Root7] A path to reducing global memory management. #18083
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: master
Are you sure you want to change the base?
Conversation
89bd358 to
4d29c60
Compare
hist/hist/src/TH1.cxx
Outdated
| Bool_t TH1::AddDirectoryStatus() | ||
| { | ||
| return fgAddDirectory; | ||
| return !ROOT::ROOT7MemoryManagement() && fgAddDirectory; |
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.
Note that this flag is primarily about file constructions (and secondarily about shared ownership). Beside the (intentional) memory leak it introduces in existing scripts, it leads most of them to not longer write the histograms to the file (because they are no longer attached to the File). It is not clear whether this kind of approach is worth it compared to a more user active change (ie. Switching explicitly from TFile to RFile).
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 for the information!
Details will be discussed on the ROOT retreat next week.
Test Results 17 files 17 suites 2d 17h 16m 36s ⏱️ For more details on these failures, see this check. Results for commit 68de9c4. ♻️ This comment has been updated with latest results. |
4d29c60 to
1224a4b
Compare
b894456 to
167c0cc
Compare
342a3cb to
0ca4f8a
Compare
Although fallbacks to the cpu backend have been implemented, trying to test RooFit without clad leads to a gtest failure, since the test suite will be instantiated three times with the same backend.
This makes TEfficiency consistent with other histogram-like classes, in the sense that it only adds itself to a directory if the corresponding flags are on.
Diffs of the outputs are fragile, so the ownership of histograms is now tested programmatically.
If implicit object ownership gets in TDirectories gets switched off, the example histograms need to be added to directories or written explicitly.
- Explain that implicit assignment to directories is likely off in R7. - Make the test insensitive to any defaults by always adding the histogram to the file.
Slightly adapt ownership test to be independent of whether ROOT's implicit ownership settings are on or off.
When histograms get added to a THStack, they are likely in multiple TLists. Therefore, the kMustCleanup bit must be set. In the past, the bit usually got set automatically when histograms added themselves to directories, but when this is disabled, the cleanup bit remained unset.
Also add an assertion to stop the test when executed in the wrong directory. Previously, the test would crash.
The test broke when implicit object ownership was switched off in ROOT. However, this test can also break in other circumstances, because del histogram generally does not destroy the C++ object immediately. It used to work because only a single reference to the object was alive (which changed when trying to prepare the test for implicit object ownership off), but one cannot base a test on undocumented details of a Python implementation. For this reason, it does not make sense to test if gDirectory (C++) contains an entry for the object that was just "del"-ed.
The function documentation explicitly states that the histograms created by these operations are added to the current directory, so this is done explicitly here.
When calling TDirectory::Append(obj, replace=true), and obj is already in the directory, return without doing anything. If obj has the same name as an existing object, but is physically different, the usual warning is raised. This will enable workflows such as: auto h = new TH1D(...); directory->Append(h, true); After this change, the above lines work both with implicit object ownership off and on. This pattern will allow writing robust programs with consistent behaviour.
Explicitly assign histograms to directories. In this way, the tests proceed irrespective of whether or not implicit object ownership is in use.
The test was relying on implicit ownership to transfer a histogram from python to C++, so now the histogram is appended explicitly.
When implicit histogram ownership is off, the co-ownership of a function both by the global list of functions and by a histogram lead to a double delete.
The tutorial was running code that didn't directly reference the histogram, so it failed when implicit ownership is off.
- Add a silentOff mode for running tests that check the program output.
…ived. - Couple TH1::AddDirectoryStatus to ROOT::DisableImplicitObjectOwnership. - Add a manual exception for TTree::Draw(): Histograms and profiles will still register themselves to gDirectory because the registration is an essential part of the feature.
- Use non-zero exit code when a test fails. - When a test fails, print the file name of the generated graphics. - Label all stressGraphics runs as longtest. - Print differences in SVGs similar to how a unified diff would be printed.
In the past, stressGraphics was retrieving a histogram from a file, modifying it and drawing it. In subsequent tests, the histogram is again read from the TFile, but this returns the in-memory object. This means that the previous tests influence the subsequent tests, e.g. whether or not statistics objects are displayed. In particular, subsequent tests will have the statistics box drawn twice, once from THistPainter::PaintStat(), and once from the fact that the box is added to the list of functions. This impacts output files such as PDF/PS/SVG. Here, the histogram is always cloned when it is retrieved from the file, so the tests are independent. The reference files for SVG are regenerated, because the statistics box is now only drawn once. Similarly, the output size of the .ps files has been corrected to reflect that the boxes are only drawn once.
0ca4f8a to
68de9c4
Compare
Details to be updated.
Needs the following PRs to be merged first: