mirror of
https://github.com/openvswitch/ovs
synced 2025-08-31 14:25:26 +00:00
ovsdb: Introduce and use specialized uuid print functions.
According to profiling data, converting UUIDs to strings is a frequent operation in some workloads. This typically results in a call to xasprintf(), which internally calls vsnprintf() twice, first to calculate the required buffer size, and then to format the string. This patch introduces specialized functions for printing UUIDs, which both reduces code duplication and improves performance. For example, on my laptop, 10,000,000 calls to the new uuid_to_string() function takes 1296 ms, while the same number of xasprintf() calls using UUID_FMT take 2498 ms. Signed-off-by: Dmitry Porokh <dporokh@nvidia.com> Signed-off-by: Eelco Chaudron <echaudro@redhat.com>
This commit is contained in:
committed by
Eelco Chaudron
parent
94500f9bb0
commit
421c94ee14
@@ -1785,7 +1785,7 @@ cmd_create(struct ctl_context *ctx)
|
||||
return;
|
||||
}
|
||||
}
|
||||
ds_put_format(&ctx->output, UUID_FMT, UUID_ARGS(&row->uuid));
|
||||
ds_put_uuid(&ctx->output, &row->uuid);
|
||||
}
|
||||
|
||||
/* This function may be used as the 'postprocess' function for commands that
|
||||
@@ -1809,7 +1809,7 @@ post_create(struct ctl_context *ctx)
|
||||
real = ovsdb_idl_txn_get_insert_uuid(ctx->txn, &dummy);
|
||||
if (real) {
|
||||
ds_clear(&ctx->output);
|
||||
ds_put_format(&ctx->output, UUID_FMT, UUID_ARGS(real));
|
||||
ds_put_uuid(&ctx->output, real);
|
||||
}
|
||||
ds_put_char(&ctx->output, '\n');
|
||||
}
|
||||
@@ -2153,7 +2153,7 @@ cmd_show_row(struct ctl_context *ctx, const struct ovsdb_idl_row *row,
|
||||
datum = ovsdb_idl_read(row, show->name_column);
|
||||
ovsdb_datum_to_string(datum, &show->name_column->type, &ctx->output);
|
||||
} else {
|
||||
ds_put_format(&ctx->output, UUID_FMT, UUID_ARGS(&row->uuid));
|
||||
ds_put_uuid(&ctx->output, &row->uuid);
|
||||
}
|
||||
ds_put_char(&ctx->output, '\n');
|
||||
|
||||
|
Reference in New Issue
Block a user