From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36341) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y0hVJ-0003xA-5o for qemu-devel@nongnu.org; Mon, 15 Dec 2014 21:04:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y0hVC-0003Y9-VW for qemu-devel@nongnu.org; Mon, 15 Dec 2014 21:04:49 -0500 Received: from mx1.redhat.com ([209.132.183.28]:47462) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y0hVC-0003X2-OY for qemu-devel@nongnu.org; Mon, 15 Dec 2014 21:04:42 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id sBG24gDt022453 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Mon, 15 Dec 2014 21:04:42 -0500 Date: Tue, 16 Dec 2014 10:04:38 +0800 From: Fam Zheng Message-ID: <20141216020438.GA18251@ad.nay.redhat.com> References: <1417664590-23707-1-git-send-email-famz@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1417664590-23707-1-git-send-email-famz@redhat.com> Subject: Re: [Qemu-devel] [PATCH v2 0/6] aio: Support epoll by introducing qemu_poll abstraction List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Paolo Bonzini , Stefan Hajnoczi , xigao@redhat.com On Thu, 12/04 11:43, Fam Zheng wrote: > v2: Emulate nanoseconds precison of timeout with ppoll and timerfd. > Their performance is on par with each other, but both much better than > qemu.git: > > syscall high # of fd low # of fd > ------------------------------------------------- > qemu.git(ppoll) 44 96 > ppoll+epoll 85 101 > timerfd+epoll 87 109 More data points. Xiaomei tested this series (applied on top of RHEL 7 qemu-kvm-rhev) and found that: 0) when # of fds is high, epoll solutions are much better (+30%). 1) timerfd+epoll is slightly better than ppoll+epoll, but the difference is minimal. 2) original code is 2%~5% faster than the new implementations when # of fds is low. This leads to the conclusion that that we'll have a small performance degradation if merge this series. I'm thinking about possible optimizations. Options in my mind are: 1) Remove 1ns PR_SET_TIMERSLACK in timerfd+epoll, this doesn't make qemu_poll faster than the old qemu_poll_ns, but may have other positive effects that compensate the cost. 2) Use dynamic switch between ppoll and timerfd+epoll. In poll-linux.c, We start with pure ppoll, while keeping track of elapsed time in ppoll. And periodically, we try "timerfd+epoll" for a few iterations, so that we can compare if it is faster than pure ppoll. If it is, swap them, use timerfd+epoll and and periodically try "ppoll". That said, I'll also look at the kernel side. Maybe optimizing ppoll or just add EPOLL_NANOSECOND_TIMEOUT to epoll_create1 is a better place for engineering. Fam > > (In high # of fd case, 3 activated but idle virtio-console devices are > attached, which will add us hundereds of fds to poll) > > v1 cover letter > --------------- > > ppoll(2) doesn't scale as well as epoll: The elapsed time of the syscall is > linear to the number of fd's we poll, which hurts performance a bit when the > number of devices are many, or when a virtio device registers many virtqueues > (virtio-serial, for instance). > > This series introduces qemu_poll, which is implemented with g_poll and epoll, > decided at configure time with CONFIG_EPOLL. > > Fam > > > Fam Zheng (6): > poll: Introduce QEMU Poll API > posix-aio: Use QEMU poll interface > poll: Add epoll implementation for qemu_poll > main-loop: Replace qemu_poll_ns with qemu_poll > tests: Add test case for qemu_poll > poll-linux: Add timerfd support > > Makefile.objs | 2 + > aio-posix.c | 52 ++++---- > async.c | 5 +- > include/block/aio.h | 7 +- > include/qemu/poll.h | 40 ++++++ > include/qemu/timer.h | 13 -- > include/qemu/typedefs.h | 2 + > main-loop.c | 35 +++++- > poll-glib.c | 130 ++++++++++++++++++++ > poll-linux.c | 314 ++++++++++++++++++++++++++++++++++++++++++++++++ > qemu-timer.c | 28 ----- > tests/Makefile | 2 + > tests/test-poll.c | 272 +++++++++++++++++++++++++++++++++++++++++ > 13 files changed, 821 insertions(+), 81 deletions(-) > create mode 100644 include/qemu/poll.h > create mode 100644 poll-glib.c > create mode 100644 poll-linux.c > create mode 100644 tests/test-poll.c > > -- > 1.9.3 > >