Skip to content

Commit

Permalink
ovsdb: row: Optimize row updates by applying diffs in-place.
Browse files Browse the repository at this point in the history
ovsdb_datum_apply_diff_in_place() is much faster than the usual
ovsdb_datum_apply_diff() in most cases, because it doesn't clone or
compare unnecessary data.  Since the original destination datum is
destroyed anyway, we might use the faster function here to speed up
transaction processing.

ovsdb_row_update_columns() with xor is mainly used by relay databases.
So, this change should improve their performance.

Acked-by: Mike Pattrick <[email protected]>
Acked-by: Han Zhou <[email protected]>
Signed-off-by: Ilya Maximets <[email protected]>
  • Loading branch information
igsilya committed Mar 3, 2022
1 parent a3e97b1 commit 015994d
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions ovsdb/row.c
Original file line number Diff line number Diff line change
Expand Up @@ -244,24 +244,18 @@ ovsdb_row_update_columns(struct ovsdb_row *dst,

for (i = 0; i < columns->n_columns; i++) {
const struct ovsdb_column *column = columns->columns[i];
struct ovsdb_datum xor_datum;
struct ovsdb_error *error;

if (xor) {
error = ovsdb_datum_apply_diff(&xor_datum,
&dst->fields[column->index],
&src->fields[column->index],
&column->type);
error = ovsdb_datum_apply_diff_in_place(
&dst->fields[column->index],
&src->fields[column->index],
&column->type);
if (error) {
return error;
}
}

ovsdb_datum_destroy(&dst->fields[column->index], &column->type);

if (xor) {
ovsdb_datum_swap(&dst->fields[column->index], &xor_datum);
} else {
ovsdb_datum_destroy(&dst->fields[column->index], &column->type);
ovsdb_datum_clone(&dst->fields[column->index],
&src->fields[column->index],
&column->type);
Expand Down

0 comments on commit 015994d

Please sign in to comment.