Skip to content

Commit

Permalink
ovsdb: monitor: Store serialized json in a json cache.
Browse files Browse the repository at this point in the history
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 <[email protected]>
Acked-by: Han Zhou <[email protected]>
Signed-off-by: Ilya Maximets <[email protected]>
  • Loading branch information
igsilya committed Aug 31, 2021
1 parent 0de8829 commit 43e66fc
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions ovsdb/monitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 43e66fc

Please sign in to comment.