Do not call std::list::size() repeatedly as it may not run in O(1) time
Until C++11, std::list::size() complexity is not necessarily O(1). It could O(N)
as it computes size() as std::distance(begin(), end()), by traversing the entire
list.
In membership manager code, there are asserts() to verify equality for sets and
maps which contain the same elements. This can churn cpu, especially when there
is a very large number of RibStates to process.
Fixed by maintaining a counter per std::list in membership manager code itself.
TODO Scan entire contrail-code base for std::list::size() and apply similar fix.
Reviewed: https:/ /review. opencontrail. org/33960 github. com/Juniper/ contrail- controller/ commit/ 5ecf49e2b131f00 8af502707edda33 3db9453d61
Committed: http://
Submitter: Zuul (<email address hidden>)
Branch: master
commit 5ecf49e2b131f00 8af502707edda33 3db9453d61
Author: Ananth Suryanarayana <email address hidden>
Date: Mon Jul 24 17:06:16 2017 -0700
Do not call std::list::size() repeatedly as it may not run in O(1) time
Until C++11, std::list::size() complexity is not necessarily O(1). It could O(N) begin() , end()), by traversing the entire
as it computes size() as std::distance(
list.
In membership manager code, there are asserts() to verify equality for sets and
maps which contain the same elements. This can churn cpu, especially when there
is a very large number of RibStates to process.
Fixed by maintaining a counter per std::list in membership manager code itself.
TODO Scan entire contrail-code base for std::list::size() and apply similar fix.
Reference: http:// en.cppreference .com/w/ cpp/container/ list/size (See Complexity)
Change-Id: Ic24725298e512f 089cdc5dbaf6070 54842ed5e23
Closes-Bug: 1706225