Sponsors

Top tips: how to make Windows slicker and faster


Share/Save/Bookmark

Taking control makes for a slicker, more efficient and more powerful PC


According to Microsoft, understanding how Windows works is no easy task. If you're a regular home user, they imply, there's no need to worry your pretty little head about such technicalities. Get back to playing games and browsing the web: leave the clever stuff to us.

Of course, this isn't entirely true. Sure, most people won't gain anything from studying the data structures that surround a Windows process, for example. However, learning just a few fundamentals can help you to improve your PC's performance, troubleshoot problems and diagnose – or prevent – system crashes. And you don't need a degree in computer science to understand these ideas, either.

Thread count

Press [CTRL]+[Shift]+[ESC] to launch Task Manager, click the Processes tab and you'll see a lengthy list of programs running on your system. Click 'Show processes from all users' (on Vista) and you'll add even more, a total of over 60 on our test PC. That's a busy setup, but the reality for your processor could be even worse.

The fact is that a Windows process doesn't 'run' anything at all. It's just a collection of data relating to a program. Every process contains at least one thread, though, and it's this that executes program code. Click 'View | Select Columns', find and check the Threads box, click 'OK' and you'll see that virtually all your processes have more than one thread. And many have considerably more: numbers of 10, 20 or 30 are by no means uncommon. Our test system had more than 600 threads listed, without opening a single application.

This doesn't mean all 600 threads want to run simultaneously, though, and Task Manager can reveal this, too. Click 'View | Select Columns', check 'CPU Time' and click 'OK': you'll see most processes have very little or no recorded CPU use at all. These are like Windows Services, set up and ready to run, but not actually consuming any CPU time until you need them for something.

Still, even if some threads are dormant, there will often be more running than your CPU can handle at once. So how does the system decide which thread gets the most attention?

Scheduling issues

Windows assigns every thread a 'quantum', which is a length of time that it's allowed to run before another thread may get a turn on your CPU. Consumer editions of Windows use a short quantum, perhaps 20 milliseconds, which means no task should be able to grab the processor for very long.

The system also triples the quantum of the foreground application, so its threads get 300 per cent more CPU time than the competition. That's a good way to ensure that whatever program you're working on stays snappy and responsive, but there's a price to pay.

Every time your CPU swaps threads it must also perform a context switch, where it saves the state of one thread and then recalls the state of the next. And this takes a short – but still measurable – amount of time. A short quantum makes for a responsive interface, then, but also increases the overhead for your CPU. It spends a lot of time just managing the system rather than getting on with running your threads.

As a result of this issue Microsoft Server products use a long quantum, six times longer than consumer Windows and so make far more efficient use of the CPU. Sounds useful? It's easy to try this for yourself. Open the System applet in Control Panel, click 'Advanced' (then 'Performance Settings | Advanced in Vista') and set 'Adjust for best performance of' to 'Background services'. Windows will now set your PC to use a long quantum with no foreground boost. This means reduced CPU overheads and better overall performance, especially on systems that run a lot of programs.

However, the new setting might mean that some programs become more jerky or games begin to stutter. If it doesn't work for you, then there's a Registry setting you can tweak: 'HKEY_LOCAL_MACHINE\ SYSTEM\CurrentControlSet\ Control\PriorityControl\Win32 PrioritySeparation'. Setting it to '16 (Hex)' delivers a long quantum with a high foreground boost to combat jerkiness. See the table on the next page for more options.

Process priority

Quantums are interesting, but the real key to thread scheduling lies in its priority. When a program is launched, its process is assigned one of six priorities: Realtime, High, Above Normal, Normal, Below Normal or Idle. Each thread for the process then inherits this priority, which is used to determine which one runs next. A High priority thread will usually be preferred to one with Normal priority, for instance.

Won't this mean some threads run all the time? Not quite. Most threads only have a limited task to perform – like 'spell check this document' – and at some point they'll be finished. And if a thread accesses hardware, perhaps opening a file, then it may enter a wait state until the device returns some information. Windows notices this and schedules another thread to run in the meantime.

In addition, a Windows component called the Balance Set Manager runs every second, looking for threads that haven't had any recent CPU attention and giving them a temporary priority and quantum boost. You'll probably have seen this at work yourself, when a process seems to grab 100 per cent of your CPU time, yet other programs still respond – though very, very slowly. That's the Balance Set Manager kicking in.

It can be useful to tweak process priorities for yourself. If a rogue process starts grabbing 100 per cent of CPU time, press [CTRL]+[Shift] +[ESC] to launch Task Manager. Select the Processes tab and click the CPU column header (click 'View | Select Columns' and check 'CPU' if you don't see it) to sort by CPU use, so you can easily spot the resource hog. Then right-click that process and choose 'Set Priority | Below Normal'. This should allow other threads to be scheduled again, letting you regain control of your PC.

You can also use 'start.exe' to launch processes with the priority of your choice. To do so, right-click your program shortcut and modify the Target to something like: cmd.exe /c START /low c:\path\app.exe.

Use '/low' for a process that you don't want to grab CPU time, or '/ high' when speed is vital. Boosting a thread's priority to High can give you a five or 10 per cent performance gain, but use this technique sparingly: remember, you're borrowing these CPU cycles from other processes and these will be slowing down. Many Windows processes also work at higher priorities and if they're blocked because you're running a game, say, your system could crash. Our advice: run only one priority-boosted app at a time and experiment with the new setting for a while before you assume that it's stable.

part 2 Of this article



--------------------------------------------------------

If you like this post please Bookmark it and comment bellow. To recieve new updates and other posts like this please subscribe via RSS or via Email.

Recent Articles:

--------------------------------------------------------

Share/Save/Bookmark

0 comments: