Reducing Context Switching

Context switching reduces server performance on any operating system: Windows 2000 is no exception. If a system is doing 50,000+ context switches per second (unlikely, but possible), it does not have time to do actual work. Instead, it is spending all its time switching various code and data pages in and out of its memory to L2 cache, RAM, or even to the disk drive; in other words, the system is thrashing.

You can reduce the amount of context switching by reducing the total number of active threads. The topics in the Transaction Programs that Run for a Long Time section describe two registry entries that can increase the thread counts for a COM+ application and Transaction Integrator (TI) two-phase commit (2PC) transactions. Be sure to adjust the thread counts to gain optimum performance. Always track the context switching per second when making adjustments to these two registry entries.

In addition to adjusting the COM+ and TI threading, you can also adjust the Host Integration Server 2006 asynchronous I/O threading model. These threads serve the Host Integration Server client traffic only, and are designed to handle the full 30,000 sessions hitting Host Integration Server with over 1,000 transactions per second (TPS). Performance testing in the Microsoft lab environment has shown no reason for adjusting these values, but if you need to minimize the thread count in your system, you can make adjustments because TI represents only one client to Host Integration Server.

Use the following information to calculate the thread count:

  • The Host Integration Server I/O thread count is equal to the base thread count plus the additional threads per CPU multiplied by the number of CPUs.
  • The base thread count is five.
  • By default, there are an additional four threads per CPU.

To adjust the thread count, specify the number of additional threads per CPU by adding a DWORD value NumberofIOthreads to the \parameter registry location. You can have up to 64 I/O threads per system.