ovsdb: Weak references performance fix
authorRodriguez Betancourt, Esteban <estebarb@hpe.com>
Wed, 13 Jul 2016 17:28:51 +0000 (17:28 +0000)
committerBen Pfaff <blp@ovn.org>
Tue, 26 Jul 2016 17:44:08 +0000 (10:44 -0700)
commitaa1fc8017ff4da75e5008d1891f80543d66a643f
tree2c0560170ee44f61bcb8bcd2b14c8e190ce2aadf
parent5b2cdc3fbbad739c09f47f420cd4f1c54c0399fb
ovsdb: Weak references performance fix

Prevents the cloning of rows with outgoing or incoming weak references when
those rows aren't being modified.

It improves the OVSDB Server performance when many rows with weak references
are involved in a transaction.

In the original code (dst_refs is created from scratch):

old->dst_refs = all the rows that weak referenced old

new->dst_refs = all the rows that weak referenced old and are still weak
+referencing new + rows in the transaction that weak referenced new

In the patch (dst_refs incrementally built):
Old->dst_refs = all the rows that weak referenced old

Ideally, but expansive to calculate:
New->dst_refs = old->dst_refs - "weak references removed within this TXN" +
+"weak references created within this TXN"

What this patch implements:
New->dst_refs = old->dst_refs - "weak references in old rows in TXN" + "weak
+references in new rows in TXN"

The resulting sets should be equal in both cases.

We do some more optimizations:

- If we know that the transactions must be successful at some point then,
  instead of cloning dst_refs we could just move the elements between
  the lists.

- At that point we lost the rollback feature, but we aren't going to need
  it anyway (note that we didn't really touch the src_refs part).

- The references in dst_refs must point to new instead than old.
  Previously we iterated over all the weak references in dst_refs
  to change that pointer, but using an UUID is easier, and prevents
  that iteration completely.

For some more commentary, see:
http://openvswitch.org/pipermail/dev/2016-July/074840.html

Signed-off-by: Esteban Rodriguez Betancourt <estebarb@hpe.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
include/openvswitch/list.h
ovsdb/row.h
ovsdb/transaction.c
tests/library.at
tests/test-list.c