2
0
mirror of https://github.com/openvswitch/ovs synced 2025-09-02 15:25:22 +00:00

ovsdb-data: Deduplicate string atoms.

ovsdb-server spends a lot of time cloning atoms for various reasons,
e.g. to create a diff of two rows or to clone a row to the transaction.
All atoms, except for strings, contains a simple value that could be
copied in efficient way, but duplicating strings every time has a
significant performance impact.

Introducing a new reference-counted structure 'ovsdb_atom_string'
that allows to not copy strings every time, but just increase a
reference counter.

This change allows to increase transaction throughput in benchmarks
up to 2x for standalone databases and 3x for clustered databases, i.e.
number of transactions that ovsdb-server can handle per second.
It also noticeably reduces memory consumption of ovsdb-server.

Next step will be to consolidate this structure with json strings,
so we will not need to duplicate strings while converting database
objects to json and back.

Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
Acked-by: Dumitru Ceara <dceara@redhat.com>
Acked-by: Mark D. Gray <mark.d.gray@redhat.com>
This commit is contained in:
Ilya Maximets
2021-09-22 09:28:50 +02:00
parent 32b51326ef
commit 429b114c5a
12 changed files with 179 additions and 130 deletions

View File

@@ -247,15 +247,15 @@ record_id_equals(const union ovsdb_atom *name, enum ovsdb_atomic_type type,
const char *record_id)
{
if (type == OVSDB_TYPE_STRING) {
if (!strcmp(name->string, record_id)) {
if (!strcmp(name->s->string, record_id)) {
return true;
}
struct uuid uuid;
size_t len = strlen(record_id);
if (len >= 4
&& uuid_from_string(&uuid, name->string)
&& !strncmp(name->string, record_id, len)) {
&& uuid_from_string(&uuid, name->s->string)
&& !strncmp(name->s->string, record_id, len)) {
return true;
}
@@ -318,14 +318,15 @@ get_row_by_id(struct ctl_context *ctx,
if (!id->key) {
name = datum->n == 1 ? &datum->keys[0] : NULL;
} else {
const union ovsdb_atom key_atom
= { .string = CONST_CAST(char *, id->key) };
union ovsdb_atom key_atom = {
.s = ovsdb_atom_string_create(CONST_CAST(char *, id->key)) };
unsigned int i;
if (ovsdb_datum_find_key(datum, &key_atom,
OVSDB_TYPE_STRING, &i)) {
name = &datum->values[i];
}
ovsdb_atom_destroy(&key_atom, OVSDB_TYPE_STRING);
}
if (!name) {
continue;