summaryrefslogtreecommitdiff
path: root/include/qapi
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2015-11-25 22:23:32 +0100
committerMarkus Armbruster <armbru@redhat.com>2015-11-26 10:07:07 +0100
commit9bada8971173345ceb37ed1a47b00a01a4dd48cf (patch)
treeaa81d4f867c5eb59e4af390ef0c9d8da8f4c2131 /include/qapi
parent95385fe9ace7db156b924da6b6f5c9082b68ba68 (diff)
downloadqemu-9bada8971173345ceb37ed1a47b00a01a4dd48cf.tar.gz
qemu-9bada8971173345ceb37ed1a47b00a01a4dd48cf.tar.bz2
qemu-9bada8971173345ceb37ed1a47b00a01a4dd48cf.zip
qjson: surprise, allocating 6 QObjects per token is expensive
Replace the contents of the tokens GQueue with a simple struct. This cuts the amount of memory allocated by tests/check-qjson from ~500MB to ~20MB, and the execution time from 600ms to 80ms on my laptop. Still a lot (some could be saved by using an intrusive list, such as QSIMPLEQ, instead of the GQueue), but the savings are already massive and the right thing to do would probably be to get rid of json-streamer completely. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Message-Id: <1448300659-23559-5-git-send-email-pbonzini@redhat.com> [Straightforwardly rebased on my patches] Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
Diffstat (limited to 'include/qapi')
-rw-r--r--include/qapi/qmp/json-streamer.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/include/qapi/qmp/json-streamer.h b/include/qapi/qmp/json-streamer.h
index e9f2937b54..09b3d3ec15 100644
--- a/include/qapi/qmp/json-streamer.h
+++ b/include/qapi/qmp/json-streamer.h
@@ -18,6 +18,13 @@
#include "glib-compat.h"
#include "qapi/qmp/json-lexer.h"
+typedef struct JSONToken {
+ int type;
+ int x;
+ int y;
+ char str[];
+} JSONToken;
+
typedef struct JSONMessageParser
{
void (*emit)(struct JSONMessageParser *parser, GQueue *tokens);