<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://www2.sqlblog.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Kalen Delaney : Hyperthreading</title><link>http://www2.sqlblog.com/blogs/kalen_delaney/archive/tags/Hyperthreading/default.aspx</link><description>Tags: Hyperthreading</description><dc:language>en</dc:language><generator>CommunityServer 2.1 SP2 (Build: 61129.1)</generator><item><title>Geek City: HyperThreaded or Not?</title><link>http://www2.sqlblog.com/blogs/kalen_delaney/archive/2007/12/08/hyperthreaded-or-not.aspx</link><pubDate>Sat, 08 Dec 2007 23:56:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:3786</guid><dc:creator>Kalen Delaney</dc:creator><slash:comments>8</slash:comments><comments>http://www2.sqlblog.com/blogs/kalen_delaney/comments/3786.aspx</comments><wfw:commentRss>http://www2.sqlblog.com/blogs/kalen_delaney/commentrss.aspx?PostID=3786</wfw:commentRss><description>&lt;P&gt;In almost all my classes, and every time I do any performance consulting, I get the question "How can I determine if our SQL Server is hyperthreaded?"&lt;/P&gt;
&lt;P&gt;I was delighted when I found the DMV sys.dm_sys_info, which has a column called hyperthread_ratio. But soon after, I read &lt;A href="http://blogs.msdn.com/buckwoody/archive/2007/08/13/script-of-the-day-find-the-cores-on-a-system.aspx"&gt;a blog post&lt;/A&gt; from one of my favorite SQL Server bloggers, Buck Woody who indicated that the following query gives you the number of cores, but doesn't specifically tell you if the hyperthreading is enabled. &lt;BR&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;SELECT cpu_count/hyperthread_ratio AS &lt;STRONG&gt;sockets&lt;/STRONG&gt;&lt;BR&gt;FROM sys.dm_os_sys_info&lt;/FONT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Although he said this gives you the number of cores, that is not correct either, because one socket can contain a &lt;A title="Wikipedia: multi-core" href="http://en.wikipedia.org/wiki/Multi-core_(computing)"&gt;multi-core&lt;/A&gt; CPU. A computer with a single socket containing a dual-core CPU and no hyperthreading will have a cpu_count value of 2, and a hyperthread_ratio of 2, and a computer with a single socket single core CPU with hyperthreading will also have the same hyperthread_ratio. In both cases, dividing hyperthread_ratio by cpu_count will give 1, the number of sockets. If we have a single socket machine with a dual-core CPU and hyperthreading, cpu_count will be 4 and hyperthread_ratio will also be four, so the ratio again will be one. So the values for single socket possibilities are summarized here:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE class="" cellSpacing=0 cellPadding=2&gt;

&lt;TR&gt;
&lt;TD class=""&gt;
&lt;P align=center&gt;&lt;B&gt;Number of Sockets&lt;/B&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD class=""&gt;
&lt;P align=center&gt;&lt;B&gt;Number of Cores&lt;/B&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD class=""&gt;&lt;STRONG&gt;Hyperthreaded?&lt;/STRONG&gt; &lt;/TD&gt;
&lt;TD class=""&gt;&lt;B&gt;sys.dm_os_info.&lt;BR&gt;cpu_count&lt;/B&gt;&lt;/TD&gt;
&lt;TD class=""&gt;
&lt;P align=center&gt;&lt;B&gt;sys.dm_os_info.&lt;BR&gt;hyperthread_ratio&lt;/B&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD class=""&gt;
&lt;P align=center&gt;&lt;B&gt;cpu_count / hyperthread_ratio&lt;/B&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class=""&gt;
&lt;P align=center&gt;1&lt;/P&gt;&lt;/TD&gt;
&lt;TD class=""&gt;
&lt;P align=center&gt;2&lt;/P&gt;&lt;/TD&gt;
&lt;TD class=""&gt;
&lt;P align=center&gt;NO&lt;/P&gt;&lt;/TD&gt;
&lt;TD class=""&gt;
&lt;P align=center&gt;2&lt;/P&gt;&lt;/TD&gt;
&lt;TD class=""&gt;
&lt;P align=center&gt;2&lt;/P&gt;&lt;/TD&gt;
&lt;TD class=""&gt;
&lt;P align=center&gt;1&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class=""&gt;
&lt;P align=center&gt;1&lt;/P&gt;&lt;/TD&gt;
&lt;TD class=""&gt;
&lt;P align=center&gt;1&lt;/P&gt;&lt;/TD&gt;
&lt;TD class=""&gt;
&lt;P align=center&gt;YES&lt;/P&gt;&lt;/TD&gt;
&lt;TD class=""&gt;
&lt;P align=center&gt;2&lt;/P&gt;&lt;/TD&gt;
&lt;TD class=""&gt;
&lt;P align=center&gt;2&lt;/P&gt;&lt;/TD&gt;
&lt;TD class=""&gt;
&lt;P align=center&gt;1&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class=""&gt;
&lt;P align=center&gt;1&lt;/P&gt;&lt;/TD&gt;
&lt;TD class=""&gt;
&lt;P align=center&gt;2&lt;/P&gt;&lt;/TD&gt;
&lt;TD class=""&gt;
&lt;P align=center&gt;YES&lt;/P&gt;&lt;/TD&gt;
&lt;TD class=""&gt;
&lt;P align=center&gt;4&lt;/P&gt;&lt;/TD&gt;
&lt;TD class=""&gt;
&lt;P align=center&gt;4&lt;/P&gt;&lt;/TD&gt;
&lt;TD class=""&gt;
&lt;P align=center&gt;1&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So even though Buck said his formula would show you the number of cores, the query itself tells the truth and the output column is named 'sockets'. The ratio of cpu_count to hyperthread_ratio shows the number of sockets, not the number of cores, and there is no way to tell the difference between hyperthreading and dual-core. &lt;/P&gt;
&lt;P&gt;I have heard that this relationship and the values returned can be different on Vista or later operating systems, but since I am not running Vista, I have no way to test it out for myself. But maybe you can. &lt;/P&gt;
&lt;P&gt;:-)&lt;/P&gt;
&lt;P&gt;Have fun!&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#ff00ff&gt;~Kalen&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://www2.sqlblog.com/aggbug.aspx?PostID=3786" width="1" height="1"&gt;</description><category domain="http://www2.sqlblog.com/blogs/kalen_delaney/archive/tags/CPUs/default.aspx">CPUs</category><category domain="http://www2.sqlblog.com/blogs/kalen_delaney/archive/tags/DMVs/default.aspx">DMVs</category><category domain="http://www2.sqlblog.com/blogs/kalen_delaney/archive/tags/Hyperthreading/default.aspx">Hyperthreading</category></item></channel></rss>