From: Paolo Bonzini <pbonzini@redhat.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v2 1/4] qjson: replace QString in JSONLexer with GString
Date: Wed, 25 Nov 2015 14:34:18 +0100 [thread overview]
Message-ID: <5655B8DA.4060808@redhat.com> (raw)
In-Reply-To: <87a8q2454l.fsf@blackfin.pond.sub.org>
On 25/11/2015 13:48, Markus Armbruster wrote:
> Where does the 3 come from?
My hat. :) I don't know---it was in the old patches, and I just brought
it on.
Oh, found it. GString adds 1 to the size (for the \0); allocating 4
bytes probably seemed like a good idea at the time.
However, it also computes the power of two that is >= size + 1, and
g_string_new uses 2 as the default length so it _also_ results in
allocating four bytes (ceil_pow2(2+1) == 4).
Paolo
> As long as g_string_truncate() doesn't reallocate, lexer->token will
> grow to hold the largest token seen so far, and stay there.
>
> Why not MAX_TOKEN_SIZE and be done with it? Oh, it's 64 MiB. Ookay,
> I'd call that... generous.
>
next prev parent reply other threads:[~2015-11-25 13:34 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-23 17:44 [Qemu-devel] [PATCH v2 for-2.5? 0/4] qjson: save a lot of memory Paolo Bonzini
2015-11-23 17:44 ` [Qemu-devel] [PATCH v2 1/4] qjson: replace QString in JSONLexer with GString Paolo Bonzini
2015-11-25 12:48 ` Markus Armbruster
2015-11-25 13:34 ` Paolo Bonzini [this message]
2015-11-23 17:44 ` [Qemu-devel] [PATCH v2 2/4] qjson: do not save/restore contexts Paolo Bonzini
2015-11-23 17:59 ` Laszlo Ersek
2015-11-23 18:09 ` Paolo Bonzini
2015-11-23 19:18 ` Laszlo Ersek
2015-11-23 20:05 ` Eric Blake
2015-11-23 20:26 ` Laszlo Ersek
2015-11-24 8:03 ` Gerd Hoffmann
2015-11-24 10:50 ` Laszlo Ersek
2015-11-24 11:18 ` Paolo Bonzini
2015-11-24 12:44 ` Fam Zheng
2015-11-24 12:54 ` Paolo Bonzini
2015-11-24 13:15 ` Markus Armbruster
2015-11-24 11:33 ` Gerd Hoffmann
2015-11-24 11:39 ` Laszlo Ersek
2015-11-25 14:32 ` Markus Armbruster
2015-11-23 17:44 ` [Qemu-devel] [PATCH v2 3/4] qjson: store tokens in a GQueue Paolo Bonzini
2015-11-23 17:44 ` [Qemu-devel] [PATCH v2 4/4] qjson: surprise, allocating 6 QObjects per token is expensive Paolo Bonzini
2015-11-23 21:00 ` [Qemu-devel] [PATCH v2 for-2.5? 0/4] qjson: save a lot of memory Eric Blake
2015-11-25 14:47 ` Markus Armbruster
2015-11-25 18:08 ` Paolo Bonzini
2015-11-25 18:34 ` Markus Armbruster
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5655B8DA.4060808@redhat.com \
--to=pbonzini@redhat.com \
--cc=armbru@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.