ovsdb: avoid unnecessary call to ovsdb_monitor_get_update()
authorAndy Zhou <azhou@ovn.org>
Mon, 22 Feb 2016 08:35:28 +0000 (00:35 -0800)
committerAndy Zhou <azhou@ovn.org>
Thu, 25 Feb 2016 00:19:08 +0000 (16:19 -0800)
Optimizing ovsdb_jsonrpc_mintor_flush_all() by avoiding calling
ovsdb_monitor_get_update() on monitors that do not have any
unflushed updates.  This change saves CPU cycles on ovsdb-server's
main loop, but should not introduce any client visible changes.

Reported-by: Liran Schour <lirans@il.ibm.com>
Signed-off-by: Andy Zhou <azhou@ovn.org>
Acked-by: Liran Schour <lirans@il.ibm.com>
Acked-by: Ben Pfaff <blp@ovn.org>
ovsdb/jsonrpc-server.c

index fffcb73..5983770 100644 (file)
@@ -1294,6 +1294,10 @@ static struct json *
 ovsdb_jsonrpc_monitor_compose_update(struct ovsdb_jsonrpc_monitor *m,
                                      bool initial)
 {
+    if (!ovsdb_monitor_needs_flush(m->dbmon, m->unflushed)) {
+        return NULL;
+    }
+
     return ovsdb_monitor_get_update(m->dbmon, initial, &m->unflushed);
 }