Skip to content

Commit

Permalink
improve dry run cpu
Browse files Browse the repository at this point in the history
Summary: When majority of the routes are in do not install / dryrun erase is o(n^2) complexity and with 1500 routes in dry run it will add some cpu load (1500*1500 route copies every time a single route changes) . replacing it with simple copy.

Reviewed By: jstrizich

Differential Revision: D15772342

fbshipit-source-id: 2e40ef3a70ff98c8bd503538aafc758157d9eddc
  • Loading branch information
Nanda Kishore Salem authored and facebook-github-bot committed Jun 12, 2019
1 parent 253b876 commit 4d93c07
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions openr/fib/Fib.cpp
Expand Up @@ -233,6 +233,7 @@ Fib::processRequestMsg(fbzmq::Message&& request) {
void
Fib::processRouteDb(thrift::RouteDatabase&& newRouteDb) {
thrift::RouteDatabase doNotInstallRouteDb;
std::vector<thrift::UnicastRoute> installUnicastRoutes;

VLOG(2) << "Processing new routes from Decision. "
<< newRouteDb.unicastRoutes.size() << " unicast routes and "
Expand All @@ -251,12 +252,14 @@ Fib::processRouteDb(thrift::RouteDatabase&& newRouteDb) {
if (rIter->doNotInstall) {
doNotInstallRouteDb.unicastRoutes.emplace_back(
*std::make_move_iterator(rIter));
rIter = newRouteDb.unicastRoutes.erase(rIter);
} else {
++rIter;
installUnicastRoutes.emplace_back(*std::make_move_iterator(rIter));
}
++rIter;
}

// Update DB with non dry run routes
newRouteDb.unicastRoutes = installUnicastRoutes;
// Find out delta to be programmed
auto const routeDelta = findDeltaRoutes(newRouteDb, routeDb_);
// update new routeDb_
Expand Down

0 comments on commit 4d93c07

Please sign in to comment.