mirror of
https://gitlab.com/qemu-project/qemu
synced 2024-11-05 20:35:44 +00:00
monitor: Reduce handle_qmp_command() tracing overhead
We are malloc'ing a QString and spending CPU cycles on converting a QObject to string, just for the sake of sticking the string in the trace message. Wasted when we aren't tracing. Avoid that. [Commit message and description suggested by Markus Armbruster to provide more detail about the rationale for this patch. Use trace_event_get_state_backends() instead of trace_event_get_state() to honor DTrace/UST backend dstates. --Stefan] Signed-off-by: Denis V. Lunev <den@openvz.org> Reviewed-by: Eric Blake <eblake@redhat.com> Message-id: 20170725143923.11241-1-den@openvz.org CC: Stefan Hajnoczi <stefanha@redhat.com> CC: Lluís Vilanova <vilanova@ac.upc.edu> CC: Dr. David Alan Gilbert <dgilbert@redhat.com> CC: Markus Armbruster <armbru@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
parent
8908eb1a4a
commit
bd6952a391
1 changed files with 5 additions and 4 deletions
|
@ -3823,7 +3823,6 @@ static void handle_qmp_command(JSONMessageParser *parser, GQueue *tokens)
|
|||
QDict *qdict = NULL;
|
||||
Monitor *mon = cur_mon;
|
||||
Error *err = NULL;
|
||||
QString *req_json;
|
||||
|
||||
req = json_parser_parse_err(tokens, NULL, &err);
|
||||
if (!req && !err) {
|
||||
|
@ -3841,9 +3840,11 @@ 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));
|
||||
QDECREF(req_json);
|
||||
if (trace_event_get_state_backends(TRACE_HANDLE_QMP_COMMAND)) {
|
||||
QString *req_json = qobject_to_json(req);
|
||||
trace_handle_qmp_command(mon, qstring_get_str(req_json));
|
||||
QDECREF(req_json);
|
||||
}
|
||||
|
||||
rsp = qmp_dispatch(cur_mon->qmp.commands, req);
|
||||
|
||||
|
|
Loading…
Reference in a new issue