mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-07-31 22:33:53 -06:00
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>
This commit is contained in:
parent
95385fe9ac
commit
9bada89711
3 changed files with 63 additions and 78 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue