qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Amit Shah <amit.shah@redhat.com>
Cc: Stefan Hajnoczi <stefanha@gmail.com>,
	Edivaldo de Araujo Pereira <edivaldoapereira@yahoo.com.br>,
	qemu-devel@nongnu.org, Bug 1066055 <1066055@bugs.launchpad.net>
Subject: Re: [Qemu-devel] [Bug 1066055] Re: Network performance regression with vde_switch
Date: Thu, 1 Nov 2012 17:50:59 +0200	[thread overview]
Message-ID: <20121101155058.GA8832@redhat.com> (raw)
In-Reply-To: <20121101151250.GA7142@amit.redhat.com>

On Thu, Nov 01, 2012 at 08:42:50PM +0530, Amit Shah wrote:
> On (Thu) 01 Nov 2012 [14:04:11], Michael S. Tsirkin wrote:
> > On Thu, Nov 01, 2012 at 02:49:18PM +0530, Amit Shah wrote:
> > > On (Tue) 23 Oct 2012 [14:55:03], Stefan Hajnoczi wrote:
> > > > On Mon, Oct 22, 2012 at 06:50:00AM -0700, Edivaldo de Araujo Pereira wrote:
> > > > > I didn't take enough time to uderstand the code, so unfortunately I fear there is not much I could do to solve the problem, apart from trying your suggestions. But I'll try to spend a little more time on it, until we find a solution.
> > > > 
> > > > I've thought a little about how to approach this.  Amit, here's a brain
> > > > dump:
> > > > 
> > > > The simplest solution is to make virtqueue_avail_bytes() use the old
> > > > behavior of stopping early.
> > > > 
> > > > However, I wonder if we can actually *improve* performance of existing
> > > > code by changing virtio-net.c:virtio_net_receive().  The intuition is
> > > > that calling virtio_net_has_buffers() (internally calls
> > > > virtqueue_avail_bytes()) followed by virtqueue_pop() is suboptimal
> > > > because we're repeatedly traversing the descriptor chain.
> > > > 
> > > > We can get rid of this repetition.  A side-effect of this is that we no
> > > > longer need to call virtqueue_avail_bytes() from virtio-net.c.  Here's
> > > > how:
> > > > 
> > > > The common case in virtio_net_receive() is that we have buffers and they
> > > > are large enough for the received packet.  So to optimize for this case:
> > > > 
> > > > 1. Take the VirtQueueElement off the vring but don't increment
> > > >    last_avail_idx yet.  (This is essentially a "peek" operation.)
> > > > 
> > > > 2. If there is an error or we drop the packet because the
> > > >    VirtQueueElement is too small, just bail out and we'll grab the same
> > > >    VirtQueueElement again next time.
> > > > 
> > > > 3. When we've committed filling in this VirtQueueElement, increment
> > > >    last_avail_idx.  This is the point of no return.
> > > > 
> > > > Essentially we're splitting pop() into peek() and consume().  Peek()
> > > > grabs the VirtQueueElement but does not increment last_avail_idx.
> > > > Consume() simply increments last_avail_idx and maybe the EVENT_IDX
> > > > optimization stuff.
> > > > 
> > > > Whether this will improve performance, I'm not sure.  Perhaps
> > > > virtio_net_has_buffers() pulls most descriptors into the CPU's cache and
> > > > following up with virtqueue_pop() is very cheap already.  But the idea
> > > > here is to avoid the virtio_net_has_buffers() because we'll find out
> > > > soon enough when we try to pop :).
> > > 
> > > This sounds doable -- adding mst for comments.
> > > 
> > > > Another approach would be to drop virtio_net_has_buffers() but continue
> > > > to use virtqueue_pop().  We'd keep the same VirtQueueElem stashed in
> > > > VirtIONet across virtio_net_receive() calls in the case where we drop
> > > > the packet.  I don't like this approach very much though because it gets
> > > > tricky when the guest modifies the vring memory, resets the virtio
> > > > device, etc across calls.
> > > 
> > > Right.
> > > 
> > > Also, save/load will become slightly complicated in both these
> > > cases, but it might be worth it.
> > > 
> > > Michael, can you comment pls?
> > > 
> > 
> > It will also complicate switching to/from vhost-net.
> > 
> > If this patch helps serial but degrades speed for -net I'm inclined
> > to simply make serial and net user different codepaths.
> 
> There's an opportunity for optimisation, let's not discount it so
> quickly.  The reporter also pointed out there was ~ +20% difference
> with tun/tap,

Seems to do with host powermanagement.

> so eliminating the call to virtqueue_avail_bytes() can
> help overall.
> 
> 		Amit

  reply	other threads:[~2012-11-01 15:48 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-12 17:34 [Qemu-devel] [Bug 1066055] [NEW] Network performance regression with vde_switch Edivaldo de Araujo Pereira
2012-10-15  8:58 ` Stefan Hajnoczi
2012-10-15 21:46 ` [Qemu-devel] [Bug 1066055] " Edivaldo de Araujo Pereira
2012-10-16  7:48   ` Stefan Hajnoczi
2012-10-22 11:18     ` Amit Shah
2012-10-22 13:50       ` Edivaldo de Araujo Pereira
2012-10-23 12:55         ` Stefan Hajnoczi
2012-11-01  9:19           ` Amit Shah
2012-11-01 12:04             ` Michael S. Tsirkin
2012-11-01 15:12               ` Amit Shah
2012-11-01 15:50                 ` Michael S. Tsirkin [this message]
2012-11-01 16:07               ` [Qemu-devel] [PATCH] virtio: limit avail bytes lookahead Michael S. Tsirkin
2012-11-02  9:56                 ` Amit Shah
2012-11-02 10:18                 ` Stefan Hajnoczi
2012-11-02 14:48                   ` Michael S. Tsirkin
2012-11-02 19:44                     ` Stefan Hajnoczi
2012-11-27 16:25                 ` Michael S. Tsirkin
2012-11-27 16:54                   ` Edivaldo de Araujo Pereira
2012-11-27 19:47                   ` Anthony Liguori
2012-11-28 21:53                   ` Michael S. Tsirkin
2012-11-29 13:04                     ` Amit Shah
2012-11-29 14:10                       ` Michael S. Tsirkin
2012-11-29 19:02                         ` Anthony Liguori
2012-11-29 22:39                           ` Michael S. Tsirkin
2012-11-01 11:42   ` [Qemu-devel] [Bug 1066055] Re: Network performance regression with vde_switch Michael S. Tsirkin
2012-10-16 12:23 ` Edivaldo de Araujo Pereira
2012-10-17 13:51   ` Stefan Hajnoczi
2018-01-10 21:28 ` Thomas Huth

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=20121101155058.GA8832@redhat.com \
    --to=mst@redhat.com \
    --cc=1066055@bugs.launchpad.net \
    --cc=amit.shah@redhat.com \
    --cc=edivaldoapereira@yahoo.com.br \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@gmail.com \
    /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).