summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Morin <thomas.morin@orange.com>2017-06-02 15:36:43 +0200
committerKevin Benton <kevin@benton.pub>2017-06-09 22:25:13 +0000
commita08aa3bf2f567d4d0a5678d470cc3a3aec382d74 (patch)
tree13c54ac3dbd3f2426e4489309a5916bd6e11a4f3
parent0d866f1743fd551633617c77e8cb65953ad9d680 (diff)
l3_ha_mode: call bulk _populate_mtu_and_subnets_for_ports
Based on the observation that a call to sync_routers can be very slow (minutes) on some setup, and that profiling data show that a significant amount of time is spent in many individual calls of _process_sync_ha_data to _populate_mtu_and_subnets_for_ports for a single interface, this change refactors _process_sync_ha_data to call _populate_mtu_and_subnets_for_ports only once on a list of interfaces instead of <n> times. Said otherwise: - before: O(#routers) SQL queries (one per network of an HA interface of a router) - after : O(1) SQL queries (on the set of networks with an HA interface on a router) A basic test shows a drastic improvements, from minutes to around one second, in the processing of a sync_routers call with 256 routers. Change-Id: I3a00c8fbb245ab3b6d93bdaa97f3435570992791 Related-Bug: 1692971
Notes
Notes (review): Code-Review+2: Armando Migliaccio <armamig@gmail.com> Code-Review+2: Brian Haley <haleyb.dev@gmail.com> Code-Review+2: Kevin Benton <kevin@benton.pub> Workflow+1: Kevin Benton <kevin@benton.pub> Code-Review+1: Tuan Luong-Anh <tuanla@vn.fujitsu.com> Verified+2: Jenkins Submitted-by: Jenkins Submitted-at: Mon, 12 Jun 2017 10:16:35 +0000 Reviewed-on: https://review.openstack.org/470428 Project: openstack/neutron Branch: refs/heads/stable/ocata
-rw-r--r--neutron/db/l3_hamode_db.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/neutron/db/l3_hamode_db.py b/neutron/db/l3_hamode_db.py
index 0f21ebc..7871f1f 100644
--- a/neutron/db/l3_hamode_db.py
+++ b/neutron/db/l3_hamode_db.py
@@ -644,10 +644,13 @@ class L3_HA_NAT_db_mixin(l3_dvr_db.L3_NAT_with_dvr_db_mixin,
644 router[constants.HA_INTERFACE_KEY] = port_dict 644 router[constants.HA_INTERFACE_KEY] = port_dict
645 router[n_const.HA_ROUTER_STATE_KEY] = binding.state 645 router[n_const.HA_ROUTER_STATE_KEY] = binding.state
646 646
647 interfaces = []
647 for router in routers_dict.values(): 648 for router in routers_dict.values():
648 interface = router.get(constants.HA_INTERFACE_KEY) 649 interface = router.get(constants.HA_INTERFACE_KEY)
649 if interface: 650 if interface:
650 self._populate_mtu_and_subnets_for_ports(context, [interface]) 651 interfaces.append(interface)
652
653 self._populate_mtu_and_subnets_for_ports(context, interfaces)
651 654
652 # If this is a DVR+HA router, but the agent is question is in 'dvr' 655 # If this is a DVR+HA router, but the agent is question is in 'dvr'
653 # mode (as opposed to 'dvr_snat'), then we want to always return it 656 # mode (as opposed to 'dvr_snat'), then we want to always return it