While reassessing weak references the code attempts to collect added
and removed atoms, even if the column didn't change.  In case the
column contains a large set, it may take significant amount of time
to process.

Add a check for the column actually being changed either by removing
references to deleted rows or by direct removal.

For example, rows in OVN Port_Group tables frequently have two large
sets - 'ports' and 'acls'.  In case a new ACL is added to the set
without changing the ports, ports don't need to be reassessed.

Fixes: 4dbff9f0a685 ("ovsdb: transaction: Incremental reassessment of weak 
refs.")
Signed-off-by: Ilya Maximets <[email protected]>
---
 ovsdb/transaction.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/ovsdb/transaction.c b/ovsdb/transaction.c
index bbe4cddc1..a482588a0 100644
--- a/ovsdb/transaction.c
+++ b/ovsdb/transaction.c
@@ -745,13 +745,17 @@ assess_weak_refs(struct ovsdb_txn *txn, struct 
ovsdb_txn_row *txn_row)
         ovsdb_datum_destroy(&deleted_refs, &column->type);
 
         /* Generating the difference between old and new data. */
-        if (txn_row->old) {
-            ovsdb_datum_added_removed(&added, &removed,
-                                      &txn_row->old->fields[column->index],
-                                      datum, &column->type);
-        } else {
-            ovsdb_datum_init_empty(&removed);
-            ovsdb_datum_clone(&added, datum);
+        ovsdb_datum_init_empty(&added);
+        ovsdb_datum_init_empty(&removed);
+        if (datum->n != orig_n
+            || bitmap_is_set(txn_row->changed, column->index)) {
+            if (txn_row->old) {
+                ovsdb_datum_added_removed(&added, &removed,
+                                          &txn_row->old->fields[column->index],
+                                          datum, &column->type);
+            } else {
+                ovsdb_datum_clone(&added, datum);
+            }
         }
 
         /* Checking added data and creating new references. */
-- 
2.43.0

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to