From owner-freebsd-questions@FreeBSD.ORG Thu Oct 8 10:33:40 2009 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CBCF41065679 for ; Thu, 8 Oct 2009 10:33:40 +0000 (UTC) (envelope-from wmoran@potentialtech.com) Received: from mail.potentialtech.com (internet.potentialtech.com [66.167.251.6]) by mx1.freebsd.org (Postfix) with ESMTP id 927A78FC14 for ; Thu, 8 Oct 2009 10:33:40 +0000 (UTC) Received: from working (pool-72-95-226-5.pitbpa.ftas.verizon.net [72.95.226.5]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.potentialtech.com (Postfix) with ESMTPSA id 826F8EBC0A; Thu, 8 Oct 2009 06:33:39 -0400 (EDT) Date: Thu, 8 Oct 2009 06:33:16 -0400 From: Bill Moran To: Pierre-Luc Drouin Message-Id: <20091008063316.6adb9fb1.wmoran@potentialtech.com> In-Reply-To: <4ACD5B80.9030703@pldrouin.net> References: <4ACD5B80.9030703@pldrouin.net> X-Mailer: Sylpheed 2.7.1 (GTK+ 2.16.6; i386-portbld-freebsd7.2) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: freebsd-questions@freebsd.org Subject: Re: When is it worth enabling hyperthreading? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Oct 2009 10:33:40 -0000 Pierre-Luc Drouin wrote: > > Hi, > > Could someone explain me in which cases it is useful to enable > hyperthreading on a machine running FreeBSD 8.0 and in which other cases > it is not a good idea? Is that possible that hyperthreading is > disadvantageous unless the number of active (non-sleeping) threads is > really high? > > For example, if I have an i7 CPU with 4 physical cores and that I run > some multi-threaded code that has only 4 threads, it will run almost > always (twice) slower with hyperthreading enabled than when I disable it > in the BIOS. If I understand correctly, hyperthreading has the advantage > of being able to do CPU context switching faster than the OS, but it > does this context switching systematically instead of only when > requested, so it slows things down unless the number of running > (non-sleeping) threads is greater or equal to let say the number of > physical threads x 1.5-1.75. I can't speak to the technical explanation, but I can give you my real- world experience. We asked this same question where I worked and had the time and ability to test it. What we found: * With hyperthreading on, workstations were more responsive to concurrent tasks. They weren't particularly faster at executing, but there were less incidents of a background task causing the UI to stall or stutter. * pgbench showed anywhere from 0% - 15% increased throughput. Kind of pathetic, but we never saw a workload on PostgreSQL that was hurt by turning hyperthreading on. -- Bill Moran http://www.potentialtech.com