From owner-freebsd-xen@FreeBSD.ORG Sat Mar 28 13:16:19 2015 Return-Path: Delivered-To: freebsd-xen@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 3D1734CA; Sat, 28 Mar 2015 13:16:19 +0000 (UTC) Received: from SMTP.CITRIX.COM (smtp.citrix.com [66.165.176.89]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (Client CN "mail.citrix.com", Issuer "Cybertrust Public SureServer SV CA" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id D1F741A2; Sat, 28 Mar 2015 13:16:18 +0000 (UTC) X-IronPort-AV: E=Sophos;i="5.11,484,1422921600"; d="scan'208";a="247515578" Message-ID: <5516A998.10206@citrix.com> Date: Sat, 28 Mar 2015 14:16:08 +0100 From: =?windows-1252?Q?Roger_Pau_Monn=E9?= User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: Andrew Daugherity , "freebsd-xen@freebsd.org" Subject: Re: Poor performance with FreeBSD 10.1 under Xen 4.2 References: <115BE54D-078A-4C45-8904-861DAB316C03@tamu.edu> In-Reply-To: <115BE54D-078A-4C45-8904-861DAB316C03@tamu.edu> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-DLP: MIA1 X-BeenThere: freebsd-xen@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Discussion of the freebsd port to xen - implementation and usage List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 Mar 2015 13:16:19 -0000 Hello, El 28/03/15 a les 0.13, Andrew Daugherity ha escrit: > Summary: FreeBSD 10.1/amd64 under Xen 4.2.5 is much slower than FreeBSD 9.3 on the same environment, especially at fork() > > > I recently installed a FreeBSD-10.1 VM under Xen, and was pleased to see the XENHVM stuff is now integrated into GENERIC. However, the system seemed a little slow and lacking in "snappiness" -- the first fetch/extraction of portsnap was particularly bad, taking at least 20 minutes. It had been a while since I'd done that (as opposed to 'portsnap fetch update') so I wasn't sure how abnormal that was, but then I noticed building stuff from ports, especially stuff using libtool, like security/sssd, was extremely slow compared to physical hardware, so I tested a 9.3 VM, which was much faster. > > Importantly, it was not a typical case of a slow/overloaded CPU but more like slow context switching/forking. I would see high (40%) system CPU percentage but low user, and usually the process at the top of the list was sh. It would take a long time between compiling files but when cc finally ran it was quite fast, compiling each file in a second or two. The system was not swapping and iostat (also xentop on the host) showed minimal I/O load. > > Tracing the sh process (which was libtool-related) with truss, I would see it do some stuff, fork, wait several seconds, then do some more stuff, rinse and repeat. Using 'truss -f' to follow the child processes, there was a noticeable delay associated with each fork() call. > > This led me to do some benchmarking. I found a fork() benchmark at [1] and ran it on various systems. Notably, on FreeBSD 10.1 (also 10.0) under Xen, it was reasonably fast shortly after bootup (though still slower than 9.3), but would get slower on repeated runs, and significantly slower after compiling some ports. It would also run slowly if the system had booted and then sat idle for a while. The speed was inconsistent, as occasionally after a period of idleness it would run somewhat faster again without rebooting; also configure and compilation times of sssd were inconsistent, but generally "slow", sometimes drastically so. > > FreeBSD 9.3 (with "xenhvm_load="YES" in loader.conf) on the same Xen host does not have this problem -- it fork()s more quickly and consistently; FreeBSD 10.1 on KVM (unfortunately not on the same hardware) also appears normal, as does 8.4 on (different but similar vintage) physical hardware, and a Linux VM on the same Xen host. Using one or two virtual CPUs does not make much difference, and the host machine is otherwise idle, so it does not appear to be an SMP issue. I was using ZFS, but I have ruled that out as a factor, as the problem occurs even without zfs.ko loaded (/ is ufs). Varying the memory between 1 and 8 GB did not seem to affect anything either. I also built a "NOHVM" 10.1 kernel to see if the Xen drivers were at issue, but that did not help (it was actually a bit slower), so it appears to be something deeper in the kernel or scheduler. > > The Xen host is running Xen 4.2.5_02-0.7.1 with SLES 11 SP3 as the Dom0, on a Dell 2950 with 8 physical CPU cores (dual socket, quad-core Xeon E5420). I have not experienced performance problems with any other guest OS. > > As FreeBSD 9.3 runs fine, I am using that for my FreeBSD VMs for now, but hopefully 10.x can be fixed before 9-STABLE goes EOL! Following are the VM config, dmesg, and some benchmarks. Thanks for the detailed description of the issue. I've reproduced your benchmarks and with the hardware I've used (Core i3-5010U) I'm not able to see this performance issue, below are the figures in my case: FreeBSD 9.3 after boot fork 1000 0.538132 FreeBSD 10.1 after boot fork 1000 0.514381 FreeBSD 9.3 build sssd 2098.66 real 1726.37 user 446.76 sys FreeBSD 10.1 build sssd 1247.38 real 1180.35 user 294.41 sys FreeBSD 9.3 after sssd fork 1000 0.543631 FreeBSD 10.1 after sssd fork 1000 0.538207 I'm Ccing feld because IIRC he found something similar on one of his boxes, that also had VTx but no EPT (just like yours). Would it be possible for you to try the same set of tests on a different hardware? Also, if even FreeBSD 10.1 compiled without XENHVM shows this issue it means there's something in the generic code that doesn't work well when running virtualized on this specific hardware, but I'm afraid figuring it out is not trivial. One place to start would be asking on freebsd-hackers and freebsd-virt. Roger.