While counting strong references current code first generates a
difference between old and new datums and only after it checks
the types of the atoms to be strong references.
Similar thing happens while assessing weak references. First
the added/removed are generated and then we check for atoms
to be weak references.
Check the type first to avoid unnecessary work. This change
doubles the performance of transactions that modify large sets
of references.
For example, with this change applied, initial read of OVSDB
file containing 136K transactions of large OVN port groups
and address sets on my laptop takes 24 seconds vs 43 seconds
without.
Fixes: 4dbff9f0a685 ("ovsdb: transaction: Incremental reassessment of weak
refs.")
Fixes: b2712d026eae ("ovsdb: transaction: Use diffs for strong reference
counting.")
Signed-off-by: Ilya Maximets <[email protected]>
---
lib/ovsdb-types.h | 12 ++++++++++++
ovsdb/transaction.c | 7 ++++++-
2 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/lib/ovsdb-types.h b/lib/ovsdb-types.h
index 9777efea3..688fe5633 100644
--- a/lib/ovsdb-types.h
+++ b/lib/ovsdb-types.h
@@ -238,6 +238,18 @@ static inline bool ovsdb_type_is_map(const struct
ovsdb_type *type)
return type->value.type != OVSDB_TYPE_VOID;
}
+static inline bool ovsdb_type_has_strong_refs(const struct ovsdb_type *type)
+{
+ return ovsdb_base_type_is_strong_ref(&type->key)
+ || ovsdb_base_type_is_strong_ref(&type->value);
+}
+
+static inline bool ovsdb_type_has_weak_refs(const struct ovsdb_type *type)
+{
+ return ovsdb_base_type_is_weak_ref(&type->key)
+ || ovsdb_base_type_is_weak_ref(&type->value);
+}
+
#ifdef __cplusplus
}
#endif
diff --git a/ovsdb/transaction.c b/ovsdb/transaction.c
index f43533a8c..bbe4cddc1 100644
--- a/ovsdb/transaction.c
+++ b/ovsdb/transaction.c
@@ -322,7 +322,8 @@ update_row_ref_count(struct ovsdb_txn *txn, struct
ovsdb_txn_row *r)
const struct ovsdb_column *column = node->data;
struct ovsdb_error *error;
- if (bitmap_is_set(r->changed, column->index)) {
+ if (bitmap_is_set(r->changed, column->index)
+ && ovsdb_type_has_strong_refs(&column->type)) {
if (r->old && !r->new) {
error = ovsdb_txn_adjust_row_refs(
txn, r->old, column,
@@ -718,6 +719,10 @@ assess_weak_refs(struct ovsdb_txn *txn, struct
ovsdb_txn_row *txn_row)
unsigned int orig_n;
bool zero = false;
+ if (!ovsdb_type_has_weak_refs(&column->type)) {
+ continue;
+ }
+
orig_n = datum->n;
/* Collecting all key-value pairs that references deleted rows. */
--
2.43.0
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev