-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
CMSEmStandardPhysicsEMMT, don't hold ref into main ParameterSet #42535
Conversation
+code-checks Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-42535/36551
|
A new Pull Request was created by @wddgit (W. David Dagenhart) for master. It involves the following packages:
@cmsbuild, @civanch, @mdhildreth can you please review it and eventually sign? Thanks. cms-bot commands are listed here |
please test |
-1 Failed Tests: HeaderConsistency Comparison SummarySummary:
|
@wddgit , what is proposed in this PR to me is not a good variant to resolve problems: we have ~20 PhysicsLists, which use few different values of parameter to configure CMS physics simulation. Creation of 20 different structs seems to be an overhead. All these parameters are used only at initialisation. I would close this PR. We will discuss with @hahnjo how to proceed with PhysicsLists. We may use this opportunity to remove unused parameters and simplify class initialisation in SimG4Core and SimG4CMS. I would expect that we should use ParameterSet without copy to local objects, we only fill local data. So, the ParameterSet may be removed after initialisation and do not save locally ParameterSet or SubParameterSet. Would this be enough? |
@makortel , @Dr15Jones , I am not sure if the idea of removing ParameterSet will work for SIM. In my memory, at super computes a new thread may appear not immediately but with big delay, so RunManagerMTWorker will be created with big delay. How it would be possible to understand that ParameterSet are not needed anymore? The only solution would be to exclude ParameterSet from RunManagerMTWorker and all thread local classes downstream. Is it a good idea? The reason of having ParameterSet is in easy configuration of CMSSW, making limitation of removing it will require changing of practically all SIM classes and creation of different mechanism of defining parameters. Do we really need this? How much of memory will be saved? |
If I understand this correctly, CMSEmStandardPhysicsEMMT is one of the approximately 20 PhysicsLists (correct me if I am wrong, I'm not familiar with this code). CMSEmStandardPhysicsEMMT is different than all the other PhysicsLists in the way it handles its parameters. It is the only one that saves a reference into the main ParameterSet and then uses it when ConstructProcess() is called. So we are only talking about creating one structure, not ~20. For example, one of the other PhysicsList, CMSEmStandardPhysicsEMH, copies the parameters directly into data members. It does not save a reference into the main ParameterSet. (Although in this particular case the values are never used at all, so I'm not sure why we even bother...) One question, when is ConstructProcess called? I was trying, but didn't yet succeed in understanding that. Is it during module construction, beginJob, run transitions, lumi transitions, event transitions, or something else. The reference might not be an actual problem if it is only used early enough. An alternative might be to copy the ParameterSet by value. There is other unrelated code doing that. Although it is a moderately large ParameterSet. Related to your second comment, there is more discussion in issue #42503. There it says 40 MB, although this varies with different jobs. I will look at RunManagerMTWorker. I am not familiar with that. Possibly @makortel will be able to comment on that. I agree that one difficulty with this approach is finding all these references (existing ones and worrying about new ones being added). |
After #34899 this is actually no longer the case, as the "worker threads" corresponding to each framework stream are created in the cmssw/SimG4Core/Application/plugins/OscarMTProducer.cc Lines 115 to 120 in ed6d0cc
So in principle simulation should be able to parse the configuration at the module construction time? But note that we are only prohibiting holding references to the Maybe the argument Within the classes inheriting from
Depends on the complexity of the job configuration. In the case of a Run 3 re-reco job (that was having memory problems) the process ParameterSet took about 40 MB. |
From @makortel: "Maybe the argument ParameterSet is already owned elsewhere within OscarMTProducer? If that is the case, this PR is indeed not needed." I'm looking to see if that is the case. If it is, I'll close the PR. That possibility didn't occur to me but I should have thought of that possibility. |
Closing, because this PR is not needed. Apologies for wasting time on this. The ParameterSet being used here is a by value data member of RunManagerMT. It is not the one owned by the Framework. This is the only usage of this class currently in CMSSW. See: https://cmssdt.cern.ch/dxr/CMSSW/source/SimG4Core/Application/interface/RunManagerMT.h#108
|
May be we should review OscarMTProducer, RunManagerMT, and RunManagerMTWorker coping and storing locally only branches of ParameterSet locally? Our branches are limited in size. Full ParameterSet should not be copied. |
m_pPhysics is not storing the entire top level process ParameterSet and also not the top level ParameterSet for the module either. I'm not sure if that is what you meant. It is only storing the nested ParameterSet named Physics. There are other similar ParameterSets stored in the same class that I didn't look at. Maybe there can be some improvements. I didn't get deep enough into it to know the answer to that. m_pPhysics is only storing the following nested ParameterSet from g4SimHits_cfi.py. I don't know how much of it is needed or used. Down the one stack code I looked only 5 parameters were used, but there could be other places in the code that use much more of it.
|
@wddgit , there is "m_p" inside RunMangerMT and/or inside RunManagerMTWorker, which may be a problem. I will try to substitute it by branches or by few variables. Also may be a part of initialisation may be moved to the constructor. |
PR description:
In an effort to reduce memory usage we are attempting to remove references into the main ParameterSet from modules. When that effort is complete, the intent is to submit a separate PR deleting that ParameterSet when all module construction is complete.
This PR addresses the last module in the Sim* subsystems with such a reference.
This copies the required parameters into a struct and holds that until it is needed instead of holding a reference to the entire ParameterSet.
PR validation:
The change is fairly trivial, but I'd like to run a manual test that the values are going through OK. The parameters are set in g4SimHits_cfi.py (only there). I've so far unsuccessfully been looking for an existing test that executes the function CMSEmStandardPhysicsEMMT::ConstructProcess(). This looks like code that might still be actively used. I am still looking. Could someone point me to a test that runs it, maybe a RelVal number?