From 9bada8971173345ceb37ed1a47b00a01a4dd48cf Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Wed, 25 Nov 2015 22:23:32 +0100 Subject: 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 Message-Id: <1448300659-23559-5-git-send-email-pbonzini@redhat.com> [Straightforwardly rebased on my patches] Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake --- include/qapi/qmp/json-streamer.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'include/qapi') diff --git a/include/qapi/qmp/json-streamer.h b/include/qapi/qmp/json-streamer.h index e9f2937..09b3d3e 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); -- cgit v1.1