Wednesday, March 4, 2009

Correctly set your level 2 cache and improve performance !!

I read about this trick the other day over Internet. Open Registry by going
to START-RUN and typing REGEDIT. Navigate to
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory
Management\SecondLevelDataCache. Based on the kind of CPU you have, this
value should change. Here are some of the defaults. Intel Celeron - 128 ,
AMD Duron - 64. PII and Athalon: 512. Cyrix and AMD K6-3 256. Pentium IV-
1024. Figure out what your CPU type is and what L2 cache it supports and
set it accordingly. It is important to know what critics have to say about
this tweak. Opinions vary and I have put following three articles that have
been brought to my attention which may help you understand why it may not
be effective in some situations:
Do not change the SecondLevelDataCache entry (from Microsoft technet
article
nol/windows2000serv/reskit/serverop/part2/sopch06.asp>)
Some third-party sources have erroneously reported that modifying the
SecondLevelDataCache registry entry in HKEY_LOCAL_MACHINE \System
\CurrentControlSet \Control \Session Manager\Memory Management can enhance
system performance. The second level (L2) cache is recognized by the
operating system and is fully utilized regardless of the setting of this
parameter.
(from Microsoft knowledge base item Q183063
)This is
not related to the hardware; it is only useful for computers with direct-
mapped L2 caches. Pentium II and later processors do not have direct-
mapped L2 caches. SecondLevelDataCache can increase performance by
approximately 2 percent in certain cases for older computers with ample
memory (more than 64 MB) by scattering physical pages better in the address
space so there are not so many L2 cache collisions. Setting
SecondLevelDataCache to 256 KB rather than 2 MB (when the computer has a 2
MB L2 cache) would probably have about a 0.4 percent performance penalty.
(From an arstechnica article
1.html>) One of the most infamous NT tweaks since the introduction of NT4
has got to be the "L2 cache" tweak, a lone registry entry which stipulates
the amount of L2 cache (or secondary cache) that the OS will make use of.
Well, as with many things in life, the effects of this tweak are not so
black and white. If you're using a processor that implements a direct-
mapped L2 cache design (like Pentium I's), then this registry adjustment is
indeed for you. However, if you own any Intel processor post-PI, or any
modern AMD processor (K6-2 and newer), then your processor is using a set-
associative L2 cache design, and thus you need not specify your L2 cache
size. Let me explain.
If you choose not to futz with the registry key in question, the OS will
call on the HAL (Hardware Abstraction Layer) for retrieval of the L2 cache
size when you boot your computer. If this happens to fail, a default value
of 256KB is used for all logon sessions on that boot session. This is where
the myth that NT can only use 256KB of L2 cache comes from. But it's false.
See, the HAL is able to retrieve the processor (L2) cache from any
processor using the set-associative cache design, it's only the relatively
few processors out there with direct-mapped L2 caches that the HAL won't
chat it up with. Thus, this tweak only applies to a select number of people
anymore (like people with Pentium I procs between 166-233MHz, as lower
rated procs had only 256KB cache).

No comments:

Post a Comment