[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v3 4/5] qtest: precompute hex nibs
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PATCH v3 4/5] qtest: precompute hex nibs |
Date: |
Thu, 07 May 2015 14:27:28 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 |
On 05/06/2015 10:18 AM, John Snow wrote:
>> To find out, add just buffering. Something like this in your patch
>> instead of byte2hex():
>>
>> for (i = 0; i < len; i++) {
>> - qtest_sendf(chr, "%02x", data[i]);
>> + snprintf(&enc[i * 2], 2, "%02x", data[i]);
>> }
>>
>> If the speedup is pretty much entirely due to buffering (which I
>> suspect), then your commit message could use a bit of love :)
>>
>
> When you're right, you're right. The difference may not be statistically
> meaningful, but with today's current planetary alignment, using
> sprintf() to batch the sends instead of my home-rolled nib computation
> function, I can eke out a few more tenths of a second.
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).
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
- [Qemu-devel] [PATCH v3 0/5] qtest: base64 r/w and faster memset, John Snow, 2015/05/05
- [Qemu-devel] [PATCH v3 4/5] qtest: precompute hex nibs, John Snow, 2015/05/05
- Re: [Qemu-devel] [PATCH v3 4/5] qtest: precompute hex nibs, Markus Armbruster, 2015/05/06
- Re: [Qemu-devel] [PATCH v3 4/5] qtest: precompute hex nibs, John Snow, 2015/05/06
- Re: [Qemu-devel] [PATCH v3 4/5] qtest: precompute hex nibs, Markus Armbruster, 2015/05/06
- Re: [Qemu-devel] [PATCH v3 4/5] qtest: precompute hex nibs, John Snow, 2015/05/06
- Re: [Qemu-devel] [PATCH v3 4/5] qtest: precompute hex nibs, Markus Armbruster, 2015/05/07
- Re: [Qemu-devel] [PATCH v3 4/5] qtest: precompute hex nibs, John Snow, 2015/05/07
- Re: [Qemu-devel] [PATCH v3 4/5] qtest: precompute hex nibs,
Eric Blake <=
- Re: [Qemu-devel] [PATCH v3 4/5] qtest: precompute hex nibs, Markus Armbruster, 2015/05/08
- Re: [Qemu-devel] [PATCH v3 4/5] qtest: precompute hex nibs, John Snow, 2015/05/08
- Re: [Qemu-devel] [PATCH v3 4/5] qtest: precompute hex nibs, Eric Blake, 2015/05/08
[Qemu-devel] [PATCH v3 1/5] qtest: allow arbitrarily long sends, John Snow, 2015/05/05
[Qemu-devel] [PATCH v3 3/5] qtest: add memset to qtest protocol, John Snow, 2015/05/05
[Qemu-devel] [PATCH v3 2/5] qtest: Add base64 encoded read/write, John Snow, 2015/05/05
[Qemu-devel] [PATCH v3 5/5] libqos/ahci: Swap memread/write with bufread/write, John Snow, 2015/05/05
Re: [Qemu-devel] [PATCH v3 0/5] qtest: base64 r/w and faster memset, Paolo Bonzini, 2015/05/06