Comment 14 for bug 1706225

Revision history for this message
OpenContrail Admin (ci-admin-f) wrote : A change has been merged

Reviewed: https://review.opencontrail.org/33960
Committed: http://github.com/Juniper/contrail-controller/commit/5ecf49e2b131f008af502707edda333db9453d61
Submitter: Zuul (<email address hidden>)
Branch: master

commit 5ecf49e2b131f008af502707edda333db9453d61
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)
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.

Reference: http://en.cppreference.com/w/cpp/container/list/size (See Complexity)

Change-Id: Ic24725298e512f089cdc5dbaf607054842ed5e23
Closes-Bug: 1706225