From: Eric Blake <eblake@redhat.com>
To: John Snow <jsnow@redhat.com>, Markus Armbruster <armbru@redhat.com>
Cc: pbonzini@redhat.com, qemu-devel@nongnu.org, afaerber@suse.de
Subject: Re: [Qemu-devel] [PATCH v3 4/5] qtest: precompute hex nibs
Date: Fri, 08 May 2015 13:47:15 -0600 [thread overview]
Message-ID: <554D12C3.8040308@redhat.com> (raw)
In-Reply-To: <554CE2CA.2080005@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 1772 bytes --]
On 05/08/2015 10:22 AM, John Snow wrote:
>>> I'm a bit surprised - making a function call per byte generally executes
>>> more instructions than open-coding the conversion (albeit the branch
>>> prediction in the hardware probably does fairly well over long strings,
>>> since it is a tight and predictable loop). Remember, sprintf() has to
>>> decode the format string on every call (unless the compiler is smart
>>> enough to open-code what sprintf would do).
>>
>> John's measurements show that the speed difference between snprintf()
>> and a local copy of formatting code gets thoroughly drowned in noise.
>>
>> The snprintf() version takes 18 lines less, according to diffstat. Less
>> code, same measured performance, what's not to like?
>>
>> However, if you feel strongly about avoiding snprintf() here, I won't
>> argue further. Except for the commit message: it needs to be fixed not
>> to claim avoiding "printf and friends" makes a speed difference.
>>
>
> My reasoning was the same as Markus's: the difference was so negligible
> that I went with the "less home-rolled code" version.
>
> I already staged this series without the nib functions and submitted the
> snprintf version as its own patch with a less disparaging (to printf and
> friends) commit message.
>
> Any further micro-optimization is a waste of time to properly benchmark
> and split hairs. I already dropped the test from ~14s to ~4s. Good enough.
Okay, I'm convinced - keep the s[n]printf, on the grounds that it wasn't
the bottleneck. You are right that premature optimization is not worth
the complexity if it gives no real speed gain.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]
next prev parent reply other threads:[~2015-05-08 19:47 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-05 22:22 [Qemu-devel] [PATCH v3 0/5] qtest: base64 r/w and faster memset John Snow
2015-05-05 22:22 ` [Qemu-devel] [PATCH v3 1/5] qtest: allow arbitrarily long sends John Snow
2015-05-05 23:22 ` Eric Blake
2015-05-05 23:35 ` John Snow
2015-05-05 22:22 ` [Qemu-devel] [PATCH v3 2/5] qtest: Add base64 encoded read/write John Snow
2015-05-05 22:22 ` [Qemu-devel] [PATCH v3 3/5] qtest: add memset to qtest protocol John Snow
2015-05-05 22:22 ` [Qemu-devel] [PATCH v3 4/5] qtest: precompute hex nibs John Snow
2015-05-06 6:25 ` Markus Armbruster
2015-05-06 14:12 ` John Snow
2015-05-06 15:19 ` Markus Armbruster
2015-05-06 16:18 ` John Snow
2015-05-07 6:13 ` Markus Armbruster
2015-05-07 17:52 ` John Snow
2015-05-07 20:27 ` Eric Blake
2015-05-08 6:25 ` Markus Armbruster
2015-05-08 16:22 ` John Snow
2015-05-08 19:47 ` Eric Blake [this message]
2015-05-05 22:22 ` [Qemu-devel] [PATCH v3 5/5] libqos/ahci: Swap memread/write with bufread/write John Snow
2015-05-06 14:56 ` [Qemu-devel] [PATCH v3 0/5] qtest: base64 r/w and faster memset Paolo Bonzini
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=554D12C3.8040308@redhat.com \
--to=eblake@redhat.com \
--cc=afaerber@suse.de \
--cc=armbru@redhat.com \
--cc=jsnow@redhat.com \
--cc=pbonzini@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.