From owner-freebsd-smp Wed May 22 12: 3:42 2002 Delivered-To: freebsd-smp@freebsd.org Received: from scaup.prod.itd.earthlink.net (scaup.mail.pas.earthlink.net [207.217.120.49]) by hub.freebsd.org (Postfix) with ESMTP id 23EBA37B42F for ; Wed, 22 May 2002 12:03:21 -0700 (PDT) Received: from pool0319.cvx21-bradley.dialup.earthlink.net ([209.179.193.64] helo=mindspring.com) by scaup.prod.itd.earthlink.net with esmtp (Exim 3.33 #2) id 17AbOE-0002Hi-00; Wed, 22 May 2002 12:03:14 -0700 Message-ID: <3CEBEB52.423171B3@mindspring.com> Date: Wed, 22 May 2002 12:02:42 -0700 From: Terry Lambert X-Mailer: Mozilla 4.7 [en]C-CCK-MCD {Sony} (Win98; U) X-Accept-Language: en MIME-Version: 1.0 To: Doug Rabson Cc: Alfred Perlstein , "Dorr H. Clark" , freebsd-smp@FreeBSD.ORG Subject: Re: hyperthreading: myth or legend? (was Re: hyperthreading? (was Re: question)) References: <20020514222840.GB1585@elvis.mu.org> <20020522172759.GV54960@elvis.mu.org> <200205221917.37801.dfr@nlsystems.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-smp@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org Doug Rabson wrote: > > A benchmarking utility reports equivelant performance to a 4 way > > machine. > > One thing we don't do which we could use to squeeze extra performance is to > adjust the allocation of cpus to procs. When one hyperthread is idle on a cpu > while the other one is running, the running hyperthread is faster since it > can use more functional units. When we schedule a new thread, we should > prefer cpus which are totally idle (i.e. both hyperthreads are idle) and only > schedule two hyperthreads on a single cpu when there is no totally idle cpu > left. CPU affinity is the number one way to deal with this. CPU negaffinity, if it exists to promote scalability, has to make an inverse preference for logical CPUs. The Intel documentation specifically states that the speed improvement for a second logical CPU is at best "40%". This is because only idle resources are available for the second logical CPU (in fact, the Intel Hyperthreding home page states that some resources will not be available to software, if the Hyperthreading is enabled in the BIOS). For SMP, the speed up for an additional CPU is generally held to be 80%. In fact, this is not the case for FreeBSD, because it lacks the scheduler code, and uses data locks rather than code locks, so it's scaling tends to drop off exponentially, resulting in the classic "4 CPU point of diminishing returns" that Sequent overcame in the early 1980s. So while you appear to get similar performance from SMT (Hyperthreading) as you do from SMP, this is really an illusion. Simple test programs are also going to fail to show the fall off properly; specifically, testing with a small load on a relatively quiescent system (e.g. like they do on Linux) is going to give a false improvement number because of cache locality which would not be true under real world load. In the real world, you have to have affinity between threads in a thread group to avoid an unrelated process from "context busting" you. Oh yeah, forgot in the post previous: to avoid resource contention, you are expected by Intel to halt idle threads. FreeBSD's SMP idle loop doesn't halt, because it hasn't done the IPI dispatch work in the scheduler to deal with more than one thing becoming runnable at a time when one or more CPUs (or "virtual CPUs") are halted. Not halting means that there is unnecessary contention between virtual CPUs for the real CPU resources. This would drop the scaling addition "best case" from "40%" to something somewhat lower for an SMT processor, as opposed to a physically seperate SMP processor. -- Terry To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-smp" in the body of the message