qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: John Snow <jsnow@redhat.com>
To: 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: Thu, 07 May 2015 13:52:25 -0400	[thread overview]
Message-ID: <554BA659.1080607@redhat.com> (raw)
In-Reply-To: <87vbg4c3v4.fsf@blackfin.pond.sub.org>



On 05/07/2015 02:13 AM, Markus Armbruster wrote:
> John Snow <jsnow@redhat.com> writes:
> 
>> On 05/06/2015 11:19 AM, Markus Armbruster wrote:
>>> John Snow <jsnow@redhat.com> writes:
>>>
>>>> On 05/06/2015 02:25 AM, Markus Armbruster wrote:
>>>>> John Snow <jsnow@redhat.com> writes:
>>>>>
>>>>>> Instead of letting printf and friends do this for us
>>>>>> one byte at a time, fill a buffer ourselves and then
>>>>>> send the entire buffer in one go.
>>>>>>
>>>>>> This gives a moderate speed improvement over the old
>>>>>> method.
>>>>>
>>>>> Out of curiosity: how much of the improvement is due to doing our own
>>>>> buffering instead of printf()'s (assuming the stream is buffered), and
>>>>> how much is due to doing our own hex formatting instead of printf()'s?
>>>>>
>>>>
>>>> Out of ignorance: How would I measure?
>>>
>>> Heh, well played!
>>>
>>> The code before the series uses chr unbuffered:
>>>
>>>         for (i = 0; i < len; i++) {
>>>             qtest_send(chr, "%02x", data[i]);
>>>         }
>>>
>>> qtest_send() formats into two bytes, passes them to
>>> qemu_chr_fe_write_all(), which writes them to chr.
>>>
>>> The chr are typically unbuffered, so this could well produce a series of
>>> two-byte write() system calls.
>>>
>>> Adding some buffering will obviously make a difference for larger len.
>>>
>>> Whether formatting hex digits by hands can make a difference is not
>>> obvious.
>>>
>>> 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.
> 
> :)
> 
>> If there are no objections, I will stage patches 1-3 and 5, and resubmit
>> a quick v2 of just this single patch, unless you want to go ahead and
>> say that making the edit will be fine, then I will just edit it before
>> sending the pullreq.
> 
> Recommend to post the revised patch, with an updated commit message.
> 

Staged patches and dropped patch 4, thanks.

--js

  reply	other threads:[~2015-05-07 17:52 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 [this message]
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
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=554BA659.1080607@redhat.com \
    --to=jsnow@redhat.com \
    --cc=afaerber@suse.de \
    --cc=armbru@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).