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
Modernize RPCTechnicalTrigger #25267
Modernize RPCTechnicalTrigger #25267
Conversation
Dr15Jones
commented
Nov 16, 2018
- Improved memory management via std::unique_ptr or holding objects by value. This fixed several memory leaks. There are no remaining bare new or delete in this code.
- Removed unnecessary member data.
- Improved const correctness.
- Removed unnecessary virtual destructors.
- Changed to range based for loops.
- Used more efficient patterns for containers.
- Converted RPCTechnicalTrigger to a stream module.
Consolidated the setup for geometry description. If possible, converted to a constexpr.
Have CreateObject return a std::unique_ptr. Unregister never needed to call delete since new objects were created each call.
-Objects are returned by std::unique_ptr -All instances share an immutable factory
-Improved memory management via std::unique_ptr or holding objects by value. -Removed unnecessary member data. -Improved const correctness. -Removed unnecessary virtual destructors. -Changed to range based for loops. -Used more efficient patterns for containers.
The code-checks are being triggered in jenkins. |
I ran valgrind on step2 of workflow 1.0 which calls RPCTechnicalTrigger. No problem were seen. |
+code-checks Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-25267/7292 |
A new Pull Request was created by @Dr15Jones (Chris Jones) for master. It involves the following packages: L1Trigger/RPCTechnicalTrigger @nsmith-, @rekovic, @cmsbuild, @thomreis can you please review it and eventually sign? Thanks. cms-bot commands are listed here |
typename std::map<Identifier, LogicCreator>::const_iterator itr; | ||
itr = m_associations.find(id); | ||
if( itr != m_associations.end() ) { | ||
delete ( itr->second )() ; |
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.
This was not needed since the call to the function always returned a new object anyway.
|
||
private: | ||
|
||
typename std::vector<std::string> m_logkeys; |
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.
m_logkeys was only being used to call m_rbclogic.Unregister()
which was not necessary.
|
||
typename std::vector<std::string> m_logkeys; | ||
static RBCLogicType const& rbclogic() { | ||
static const RBCLogicType s_rbclogic = initialise(); |
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.
This is thread safe.
const RBCBoardSpecs * m_rbcboardspecs; | ||
std::unique_ptr<RBCLogicUnit> m_rbclogic; |
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.
The class now properly manages its own member data rather than having classes which inherit from it try to manage the memory.
@@ -32,8 +33,6 @@ class RBCEmulator { | |||
|
|||
RBCEmulator( const char * , const char * , int, int *); | |||
|
|||
virtual ~RBCEmulator( ); ///< Destructor |
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.
No classes inherit from this one.
isAoB = 1; | ||
} | ||
|
||
for ( pos = 0; pos < 6; ++pos ) { | ||
if (this->m_block->m_sec1[pos] == sector || this->m_block->m_sec2[pos] == sector ) |
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.
this->m_block
is only being used as a hidden argument to the function. I made it explicit.
@@ -363,7 +272,7 @@ void RBCProcessRPCDigis::setDigiAt( int sector, int digipos ) | |||
void RBCProcessRPCDigis::setInputBit( std::bitset<15> & signals , int digipos ) | |||
{ | |||
|
|||
int bitpos = m_layermap[digipos]; | |||
int bitpos = s_layermap.at(digipos); |
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.
This is a functional differerence. If an out of range digipos
is used, this code will now throw. The old code just added a new entry.
@@ -344,7 +267,7 @@ void RBCProcessRPCSimDigis::setDigiAt( int sector, int digipos ) | |||
void RBCProcessRPCSimDigis::setInputBit( std::bitset<15> & signals , int digipos ) | |||
{ | |||
|
|||
int bitpos = m_layermap[digipos]; | |||
int bitpos = s_layermap.at(digipos); |
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.
This is a functional difference, the code will now throw if digipos
is not in the container.
bool topRight(false); | ||
bool botLeft(false); | ||
|
||
int indxW1 = m_WheelTtu[wheel1]; | ||
int indxW2 = m_WheelTtu[wheel2]; | ||
int indxW1 = wheelTtu[wheel1+kWheelOffset]; |
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.
Previously a map was being used. But the keys were just {-2,-1,0,1,2}. So a std::vector
with an offset can do the job better.
|
||
m_ttuboardspecs = ttuspecs; | ||
|
||
m_ttulogic = new TTULogicUnit(); |
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.
This is a member data from the base class.
please test |
The tests are being triggered in jenkins. |
Running valgrind with memory leaks checking on, I do not see any memory leaks coming from this package with my changes. |
-1 Tested at: f149ded You can see the results of the tests here: I found follow errors while testing this PR Failed tests: ClangBuild
I found compilation warning while trying to compile with clang. Command used:
See details on the summary page. |
Comparison not run due to Build errors/Fireworks only changes/No short matrix requested (RelVals and Igprof tests were also skipped) |
The code-checks are being triggered in jenkins. |
+code-checks Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-25267/7293 |
please test |
The tests are being triggered in jenkins. |
Comparison job queued. |
Comparison is ready Comparison Summary:
|
DQM differences look unrelated to this PR |
+1 |
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. @davidlange6, @slava77, @smuzaffar, @fabiocos (and backports should be raised in the release meeting by the corresponding L2) |
+1 |