From 819b18b97c3d3fb2c3e42826d57009592bf6d252 Mon Sep 17 00:00:00 2001 From: Prabhjot Singh Sethi Date: Fri, 5 Jun 2015 12:31:54 +0530 Subject: [PATCH] ToR Agent OVSDB - performance on HA Issue: ------ After the initial read from OVSDB server all the previous VlanPortBindingsEntries are created as Stale entries, later on subscribing to operDB all the entries start getting converted from stale to non-stale, however the data remains same, where OVSDB client not identifying no op keeps on triggering updates on Physical Port entry, resulting in preformance degradation Fix: ---- Keep track of old_logical_switch_name in vlan port binding entry and if on change it is a no op avoid triggering updates to physical port entry Partial-Bug: #1456284 Change-Id: I4a61904056ca374a34d40823f623fc14dfbcff67 (cherry picked from commit 363ef441a60121f55a3d3cccae3efac6899a81cd) --- .../ovsdb_client/vlan_port_binding_ovsdb.cc | 16 +++++++++++++--- .../ovsdb_client/vlan_port_binding_ovsdb.h | 1 + 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/vnsw/agent/ovs_tor_agent/ovsdb_client/vlan_port_binding_ovsdb.cc b/src/vnsw/agent/ovs_tor_agent/ovsdb_client/vlan_port_binding_ovsdb.cc index 5a9a1f569e8..b498f9c3115 100644 --- a/src/vnsw/agent/ovs_tor_agent/ovsdb_client/vlan_port_binding_ovsdb.cc +++ b/src/vnsw/agent/ovs_tor_agent/ovsdb_client/vlan_port_binding_ovsdb.cc @@ -35,13 +35,14 @@ VlanPortBindingEntry::VlanPortBindingEntry(VlanPortBindingTable *table, uint16_t vlan_tag, const std::string &logical_switch) : OvsdbDBEntry(table_), logical_switch_name_(logical_switch), physical_port_name_(physical_port), physical_device_name_(physical_device), - vlan_(vlan_tag), vmi_uuid_(nil_uuid()) { + vlan_(vlan_tag), vmi_uuid_(nil_uuid()), old_logical_switch_name_() { } VlanPortBindingEntry::VlanPortBindingEntry(VlanPortBindingTable *table, const VlanLogicalInterface *entry) : OvsdbDBEntry(table_), logical_switch_name_(), physical_port_name_(), - physical_device_name_(""), vlan_(entry->vlan()), vmi_uuid_(nil_uuid()) { + physical_device_name_(""), vlan_(entry->vlan()), vmi_uuid_(nil_uuid()), + old_logical_switch_name_() { RemotePhysicalInterface *phy_intf = dynamic_cast (entry->physical_interface()); assert(phy_intf); @@ -54,7 +55,7 @@ VlanPortBindingEntry::VlanPortBindingEntry(VlanPortBindingTable *table, logical_switch_name_(key->logical_switch_name_), physical_port_name_(key->physical_port_name_), physical_device_name_(key->physical_device_name_), vlan_(key->vlan_), - vmi_uuid_(nil_uuid()) { + vmi_uuid_(nil_uuid()), old_logical_switch_name_() { } void VlanPortBindingEntry::PreAddChange() { @@ -79,6 +80,11 @@ void VlanPortBindingEntry::AddMsg(struct ovsdb_idl_txn *txn) { PhysicalPortEntry *port = static_cast(physical_port_.get()); + // update logical switch name propagated to OVSDB server, this will + // be used in change Operation to reduce the unncessary computation + // when there is change which VlanPortBindingEntry is not + // interested into + old_logical_switch_name_ = logical_switch_name_; if (!logical_switch_name_.empty()) { port->AddBinding(vlan_, static_cast(logical_switch_.get())); @@ -98,6 +104,10 @@ void VlanPortBindingEntry::AddMsg(struct ovsdb_idl_txn *txn) { } void VlanPortBindingEntry::ChangeMsg(struct ovsdb_idl_txn *txn) { + if (logical_switch_name_ == old_logical_switch_name_) { + // no change return from here. + return; + } PhysicalPortEntry *port = static_cast(physical_port_.get()); OVSDB_TRACE(Trace, "Changing port vlan binding port " + diff --git a/src/vnsw/agent/ovs_tor_agent/ovsdb_client/vlan_port_binding_ovsdb.h b/src/vnsw/agent/ovs_tor_agent/ovsdb_client/vlan_port_binding_ovsdb.h index dfc41b36040..a787bd55faf 100644 --- a/src/vnsw/agent/ovs_tor_agent/ovsdb_client/vlan_port_binding_ovsdb.h +++ b/src/vnsw/agent/ovs_tor_agent/ovsdb_client/vlan_port_binding_ovsdb.h @@ -67,6 +67,7 @@ class VlanPortBindingEntry : public OvsdbDBEntry { std::string physical_device_name_; uint16_t vlan_; boost::uuids::uuid vmi_uuid_; + std::string old_logical_switch_name_; DISALLOW_COPY_AND_ASSIGN(VlanPortBindingEntry); }; };