[Qemu-devel] [PATCH 2/2] monitor: improve tracing in handle_qmp_command

Vladimir Sementsov-Ogievskiy posted 2 patches 8 years, 3 months ago
[Qemu-devel] [PATCH 2/2] monitor: improve tracing in handle_qmp_command
Posted by Vladimir Sementsov-Ogievskiy 8 years, 3 months ago
Calculate req_json only if trace_handle_qmp_command enabled.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 monitor.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/monitor.c b/monitor.c
index 6d040e620f..3606a7928b 100644
--- a/monitor.c
+++ b/monitor.c
@@ -3823,7 +3823,7 @@ static void handle_qmp_command(JSONMessageParser *parser, GQueue *tokens)
     QDict *qdict = NULL;
     Monitor *mon = cur_mon;
     Error *err = NULL;
-    QString *req_json;
+    QString *req_json = NULL;
 
     req = json_parser_parse_err(tokens, NULL, &err);
     if (!req && !err) {
@@ -3841,8 +3841,8 @@ static void handle_qmp_command(JSONMessageParser *parser, GQueue *tokens)
         qdict_del(qdict, "id");
     } /* else will fail qmp_dispatch() */
 
-    req_json = qobject_to_json(req);
-    trace_handle_qmp_command(mon, qstring_get_str(req_json));
+    trace_handle_qmp_command(mon,
+                             qstring_get_str(req_json = qobject_to_json(req)));
     QDECREF(req_json);
 
     rsp = qmp_dispatch(cur_mon->qmp.commands, req);
-- 
2.11.1


Re: [Qemu-devel] [PATCH 2/2] monitor: improve tracing in handle_qmp_command
Posted by Stefan Hajnoczi 8 years, 3 months ago
On Fri, Jul 21, 2017 at 05:31:49PM +0300, Vladimir Sementsov-Ogievskiy wrote:
> Calculate req_json only if trace_handle_qmp_command enabled.
> 
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>

Is there a real-world performance issue?

(I'm not against this change but it's important to understand the
rationale for performance optimizations.)

The monitor is a control channel.  Anything using it at high frequency
with low latency expectations will be disappointed.  We should look at
such cases and decide whether the monitor really is the appropriate
interface for them.

Stefan