Date: Sun, 27 Mar 2005 23:33:28 +0200 From: Anthony Atkielski <atkielski.anthony@wanadoo.fr> To: freebsd-questions@freebsd.org Subject: Re: hyper threading. Message-ID: <1162017909.20050327233328@wanadoo.fr> In-Reply-To: <200503272151.06216.list-freebsd-2004@morbius.sent.com> References: <c6ef380c050326061976f164b@mail.gmail.com> <8C7006AE7E80573-FAC-3B652@mblk-r28.sysops.aol.com> <49251524.20050326234521@wanadoo.fr> <200503272151.06216.list-freebsd-2004@morbius.sent.com>
next in thread | previous in thread | raw e-mail | index | archive | help
RW writes: > Multiple processors can run multiple processes at the same time. A HT > processor can only run two threads from the same process. This is incorrect. HT processors don't care where the threads come from; it is possible to run threads from two completely different processes on the same HT processor. The threads have completely independent architectural states and can come from anywhere in the system. However, the design of hyperthreading favors a certain amount of commonality between the contexts of each thread. While it's best to have different instruction mixes, it helps if both threads are executing in the same memory spaces, since resources such as on-device cache are shared between the threads in the HT processor. Completely different threads in different processes executing out of different areas of memory might cause more contention for cache and similar resources (TLB, etc.), diminishing the advantage of hyperthreading. Also, spin waits need special consideration on HT processors. If one thread spins on a gate or semaphore held by the other thread, it effectively slows the other thread down, keeping both threads moving more slowly than they might if they were in completely separate processors. A solution for this suggested by Intel is the PAUSE instruction, which forces complete execution of a spin-wait instruction before the next execution can begin, thus freeing resources for the other thread in the processor. Intel recommends the use of PAUSE even when HT processors are not being used. Still another recommendation is to schedule first physically independent processors, then HT logical processors. This requires that the OS be aware of the difference between the two. This usually makes more efficient use of processor resources, except for some very specific cases where running two threads on the same HT processor might run as fast or faster than running them separately (if they are referencing a lot of the same shared resources, such as cache). Intel claims up to a 30% improvement in throughput for an HT processor as compared to a normal processor. For truly separate physical processors, the improvement is more like 60%, and possibly much more. Hyperthreading should not be seen as a substitute for multiple processors. It's more like a way to make better use of each processor. Hyperthreading is especially useful when multiple execution threads exist in a common context, such as multithreaded daemons or multithreaded desktop applications. In these situations, the HT architecture is used to the fullest, with corresponding improvements in performance. Recent changes in FreeBSD architecture to allow a multithreaded kernel are among the situations in which hyperthreading can be put to good use. The new multithreaded architecture of Apache 2.x should also be able to put HT to good use. -- Anthony
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1162017909.20050327233328>