summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIlya Maximets <i.maximets@ovn.org>2021-08-24 21:00:39 +0200
committerIlya Maximets <i.maximets@ovn.org>2021-09-01 00:15:30 +0200
commit43e66fc27659af2a5c976bdd27fe747b442b5554 (patch)
tree8ffdf2e094067047a3a0c74eb36cf764c36d12c3
parent0de882954032aa37dc943bafd72c33324aa0c95a (diff)
downloadopenvswitch-43e66fc27659af2a5c976bdd27fe747b442b5554.tar.gz
ovsdb: monitor: Store serialized json in a json cache.
Same json from a json cache is typically sent to all the clients, e.g., in case of OVN deployment with ovn-monitor-all=true. There could be hundreds or thousands connected clients and ovsdb will serialize the same json object for each of them before sending. Serializing it once before storing into json cache to speed up processing. This change allows to save a lot of CPU cycles and a bit of memory since we need to store in memory only a string and not the full json object. Testing with ovn-heater on 120 nodes using density-heavy scenario shows reduction of the total CPU time used by Southbound DB processes from 256 minutes to 147. Duration of unreasonably long poll intervals also reduced dramatically from 7 to 2 seconds: Count Min Max Median Mean 95 percentile ------------------------------------------------------------- Before 1934 1012 7480 4302.5 4875.3 7034.3 After 1909 1004 2730 1453.0 1532.5 2053.6 Acked-by: Dumitru Ceara <dceara@redhat.com> Acked-by: Han Zhou <hzhou@ovn.org> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
-rw-r--r--ovsdb/monitor.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/ovsdb/monitor.c b/ovsdb/monitor.c
index 532dedcb6..ab814cf20 100644
--- a/ovsdb/monitor.c
+++ b/ovsdb/monitor.c
@@ -1231,6 +1231,15 @@ ovsdb_monitor_get_update(
condition,
ovsdb_monitor_compose_row_update2);
if (!condition || !condition->conditional) {
+ if (json) {
+ struct json *json_serialized;
+
+ /* Pre-serializing the object to avoid doing this
+ * for every client. */
+ json_serialized = json_serialized_object_create(json);
+ json_destroy(json);
+ json = json_serialized;
+ }
ovsdb_monitor_json_cache_insert(dbmon, version, mcs,
json);
}