July 2001 Tuning Windows 2000 for Audio Jose-Maria Catena Windows 2000 is not exactly brand new. More than a year has elapsed since it came out, the Service Pack 2 is now available, and Win2K's successor, Windows XP, is almost out already. But the fact is that many of us had difficulties using Windows 2000 for our digital audio workstations until recently, mainly because few professional soundcards had drivers for it. Now, the time for the move has definitively arrived: many of the best soundcard manufacturers are providing drivers for Windows 2000, and the best music applications are ready to run on it. Some applications like SONAR and SAW Studio have been optimized specifically for Windows 2000. But the Windows 2000 feature that everyone will love in first place is stability. Anyone that was using the 9X family - Windows 95, Windows 98 or Windows Me - knows what I mean. Certainly, Windows 2000 is far more robust and stable comparable than 9X operating systems. Windows 2000 runs very well "out of the box", that is, the default configuration parameters are adequate for DAW use. But there are choices and settings that affect DAW performance, and this is our business here: this article intends to help you to get the most out of Windows 2000. My intention is not to list a couple of recipes. I always prefer to explain how certain configurations behave, so you can understand and choose accordingly. It may be a bit harder, but I will try to keep the details easy for most users, and at the end you should know better what you have in your hands instead of having to follow recipes that you do not understand and that in many cases are harmful - yes, I have read a lot of misguided information about Windows 2000 tweaks out there. Windows 2000 requirements The minimum amount of RAM is 32 MB, but this is really too little, the system will run very slowly due to constant virtual memory usage. For good performance, the minimum I would recommend is 128 MB, and 256-512 MB is what I consider the adequate amount for most cases. Before Windows 2000 installation: ACPI Before installing Windows 2000, check if there is a BIOS update for your mainboard, especially if it contains any fix regarding ACPI or Windows 2000, and flash it following the instructions from the manufacturer. If the BIOS allows you to enable and disable the ACPI functionality, now is the time to disable it. ACPI uses an additional interrupt and in my personal opinion does not add any useful feature to a desktop computer (a laptop is another story), so I prefer it disabled. Having ACPI enabled is not a problem unless there is a bug in the ACPI BIOS, so you can enable it if desired for any reason. However, if you experience problems, and have ACPI enabled, consider disabling it. During setup, Windows 2000 will detect if your BIOS supports ACPI or not. If you decided to leave ACPI disabled, you may want to enable APM (Advanced Power Management) after the system is installed, so that the system can switch off the system after shutdown. You can do so at Control Panel > Power Options, in the APM tab. File system: FAT32 or NTFS? Windows 2000 supports an additional file system that is not supported by the Win9X family: NTFS. This file system incorporates many improvements, among others:
The problem is that none of these great new improvements are needed at all for audio applications. NTFS performance is slightly worse in most cases than FAT32 as shown by both DskBench and SONAR, but only by a little bit, less than 10% in the largest case. Also, defragmenting a NTFS volume may take longer than a FAT32 volume. I would suggest the following guidelines:
Early during installation Win2K will ask you to convert the installation partition to NTFS. Choose according to what you need. If you need compatibility for Windows 98 – especially if you want to dual-boot – don't convert. Win2K includes also a FAT32 to NTFS converter that you can use on any other partition once the system is installed, but be cautious: backup first. Dual Boot The compatibility with legacy software in Windows 2000 is very restricted compared with Windows 9X, and this is mostly required to ensure stability against any kind of application failure or offense. In general, you can't run programs that access the hardware directly, in particular DOS games and direct disk access programs. If any offending program is run, Windows 2000 will stop it as soon as it tries to access something that it should not, but it will not create any instability in Windows 2000 itself. If you need to run such programs, or want to retain Win9X for some reason, be sure to install Windows 2000 in a dual boot configuration, so that you can still boot Win9X or DOS in case of necessity. This is a good idea anyway, and you can always remove the other OS later when it is not longer necessary. Dual boot will let you migrate safely to Windows 2000 and will allow you to always get back to your old working system just in case something doesn't work in Windows 2000. To install Windows 2000 in a dual boot configuration, have your older OS installed first, and then, start the Windows 2000 setup from it. When prompted do not upgrade to Windows 2000 but instead select "Install a new copy (clean install)", and specify a new directory for it when asked. Microsoft recommends installing it in a different partition than your other OS. This is not strictly necessary, and I for one have both W98SE and W2K in the same partition. But if you decide to use the same partition: do not convert it to NTFS! One interesting trick to do is to rename the W9X swap file so that it uses the same as Windows 2000, resulting in less wasted space. Since both systems will not ever run at the same time, this is safe. First configure the virtual memory in both systems so that it is placed in the same FAT32 volume, and make the minimum size the same for both OSs. Edit the SYSTEM.INI file in the W9X directory, locate the "PagingFile=" line and change the name to PAGEFILE.SYS. Reboot and delete the old WIN328.SWP file. That's all. It won't make your computer any faster, but it will reclaim wasted space on your disk. Most applications can be installed in the same directory for both operating systems, saving space. You can also configure some applications like e-mail clients so that they use the same location for data files in both systems. Virtual Memory Windows 2000 does not allow disabling virtual memory. This is not a problem. I never recommend disabling VM, and Windows 2000 manages it much better than Win9X. You can choose the disk volume where the VM file will be placed. Usually you will want a single file. If you have several disks, do not put it in the same disk that you use for the audio files. The settings recommended by Windows 2000 are usually adequate, but some tweaking can prevent possible problems. When you are running Windows 2000, it will use the smallest swap file it needs. But if you do something that requires more RAM, Windows will enlarge the swap file to create memory headroom. If this happens when you're recording or playing back, you could experience real performance problems when Windows tries to enlarge the swap file. Therefore, set the minimum virtual memory size so that the swap file should never need to grow. 256 MB should be the smallest value you should set, but 384 to 512 MB are better. The maximum size should be set at a large value, for example 1024 or even more. There is not harm in having a large maximum value setting, just don't overfill your hard disk or the swapfile may be prone to fragmentation. If you wish you can set both values to the same large value, say 512 or 1024 MB, and Windows will never resize your swap file. Disabling Visual Effects Disable them! Go to Control Panel > Display > Effects Tab and disable "Use transition effects…". It's also a good idea to disable "Show window contents while dragging". Or better, download and install the latest version of TweakUI from Microsoft, and disable every kind of visual effects and animations. As principle, when the CPU is busy with high priority intensive tasks (like audio processing) the "transition effects" should perform slowly, giving CPU priority to the higher-priority tasks like audio. But apparently someone at Microsoft thought that was not acceptable – that smooth visual effects were more important - so they decided to assign a higher priority to the visual effects task. Consequence: displaying a menu or a tooltip can steal time from more critical tasks. Disabling those effects helps ensure that a pretty drop-down menu doesn't cause a frustrating dropout. Another thing I always disable are the system sounds. Go to Control Panel > Sounds And Multimedia and select "No Sounds". I also disable web contents in folders Control Panel > Display > Web. Another good idea is to avoid desktop background and themes and screen savers. Use the power saving options instead. If you do not need 24/32 bit color, use 16 bit color. Screen redraws and updates take usually less CPU time in this mode and your applications should look just fine with 16 bit color. Bus Mastering ATA Controller Drivers Windows 2000 will detect and activate DMA modes by default whenever it recognizes the disk controller as DMA capable for any DMA capable device connected. You can review the mode set or change it at Device Manager > IDE ATA / ATAPI Controllers > Primary (and Secondary) Controller > Advanced Settings Tab. It only allows to set "PIO only" or "DMA if possible" for each device, and indicates the currently active mode. But does not show the actual PIO or DMA speed. If you do not see these settings, or you cannot enable DMA mode for a device that you know supports it (which includes all modern devices), your controller may not have been recognized properly by Windows 2000 and you may need to install specific drivers provided by the manufacturer. Of course, all Intel chipsets are recognized and perform very well. Mileage with others may vary very much. In particular, the VIA 686A performs particularly bad. At any rate, you need to have DMA enabled for all of your drives, especially your audio disks. This is absolutely essential for good DAW performance – a system which can stream 100 tracks of audio in DMA can grind to a halt at only 12 tracks in PIO mode! Remember that special 80 wire ATA cables are required for UDMA66 or UDMA100 operation, and highly recommended even for slower modes. If you are still using 40 wire cables, change them immediately, even if you're running UDMA33. The extra 40 wires aren't attached to anything – they just serve as shielding between every other wire. The result is less interference and fewer errors - which means fewer retries and faster performance. File I/O Optimization Windows 2000 file I/O is very efficient, more than Win9X, and you do not need to tweak any special setting in the operating system – specifically, the VCACHE setting which was so important in optimizing Windows 98 systems is not needed in Windows 2000. All you need to do is properly format your disks. Use FAT32 with 32KB clusters when formatting volumes for audio files - FORMAT [drive-letter]: /z:64 Disk performance statistics can be disabled: type "diskperf –n" at a command prompt. They will remain disabled after subsequent boots. To enable them back, type "diskperf -y". Disabling disk statistics may improve the file I/O efficiency a bit. Power Management Options It is better to avoid screen savers, and use instead the power saving modes for the monitor (Control Panel > Power Options). It is also preferable to not activate the automatic hard disk power down. Normally, start and stop cycles contribute more to hard disk wearing than "on time". Also disable any options that throttle back the CPU when it is unused. These settings are useful for battery powered devices but offer no benefit to an AC-powered computer. Less is More Windows 2000 runs a couple of services that many of us will never use. These steal a very little amount of CPU time, but can waste some memory and startup time. So if you do not need a service, it is a good idea to disable its automatic loading at startup. You can do so going to Control Panel > Administrative Tools > Services. Look for any unneeded service with automatic startup type, and change it to manual. With this setting, the service will not start automatically at Windows startup, but can be started if needed. Typical services that might not be necessary:
Additionally, if you aren't using a LAN, you should be able to disable:
An important tweak in Windows 98 for DAWs was to turn off CD autoplay. The computer spends some amount of time determining if a CD has been inserted, and if it has, the computer then attempts to auto-run it. By turning off CD autoplay we were able to get improved performance and stability when tracking. This tweak no longer offers a significant performance benefit and we no longer need to make it. The only point to be made is that if you are recording or performing a critical task, just don't insert a CD into the drive, or it will get priority and probably stop your critical task. Do Not Touch Default Priority Settings You may have seen advices recommending an increase of the default priority settings. This is a bad idea. Don't do it. Programs can set the appropriate priorities for any process or thread. Programmers require advanced skills in multitasking to analyze and design the appropriate priorities scheme for a given program. For example, in a DAW, the soundcard buffer events are of very high real-time priority, since if they are not serviced in few milliseconds, a dropout will occur. The file pre-read threads must have a lower priority, but still higher than window redraws, and so on. Even DskBench uses several threads with very specific priority each. You do not have access to change the programmer assigned priorities. So some people have recommended increasing the default priority. Increasing the default priority only raises the priorities of all threads in the system for which the programmers did not assign a specific priority. This means that these threads do not have any special timing requirement, and you might make them take precedence over threads that require faster responses. In the worst case, it may be true that many application programmers do not have the adequate skills to properly design the priorities schemes or even basic multitasking issues. But there is nothing you can do about that other than making things worse, unless you are truly an expert willing to spend some time face to face with SoftICE to improve someone else's binaries. Software Compatibility and the WIN32 API Windows 2000 shares the same basic API (Applications Programming Interface) with Windows 95, Windows 98, Windows Me and NT4: the WIN32 API. More accurately, the Windows 2000 version is a superset of the others. I must add an important note here: the code that implements the WIN32 API functions in Windows 2000 is 100% 32-bit code. Just to support 16-bit legacy applications, there are also 16-bit libraries that just call to the 32-bit ones to perform the tasks. That is the right way to implement 16-bit compatibility, but, as you surely know, the 9X family worked in the opposite way: the functionality was written in 16-bit code, and the WIN32 API was implemented by 32-bit libraries which called the 16-bit ones! This means that Windows 2000 is truly a 32-bit OS, unlike the 9X family. Anyway, there are very few compatibility problems in the WIN32 API other than very rare side effects of implementation differences. Most pure WIN32 applications will run on Windows 2000 as well or better than on the 9X OSs. If you find some of the few 32 bit applications that do not run fine on Windows 2000, you should contact the provider for an update. Multimedia and Other Newer APIs Windows 2000 is ahead of any other older Microsoft OS in all aspects. It includes or can host the newer APIs and most recent versions of any API available, and can run all of them better than any older OS. I have read all kinds of statements like "Windows 2000 is not optimized for audio", "Windows 9X/Me is the best choice for multimedia", etc. Surely people saying that were confused by the fact that NT4, the predecessor of Windows 2000, did not receive adequate support for multimedia. But this is not the case in Windows 2000 at all. Keep in mind that DirectX 8 was targeted for Windows 2000 in first place, and that the first beta only ran on Windows 2000. Microsoft is clearly targeting Windows 2000 for multimedia. Here's the deal. The key factors for multimedia applications - or any other applications requiring precise timing and massive I/O and processing - are the task scheduler latencies and I/O efficiency. In both, Windows 2000 beats any older OS hands down, in particular the extremely important scheduler latency, which is at least two orders of magnitude better than in the 9X family. Although the huge variety of hardware and software configurations out there makes very difficult to define figures valid in all scenarios, in the average PC Windows 2000 is able to meet worst case high priority task latencies close to 1 ms, while Windows 9X does not even meet 100 ms. Worst-case high priority task latency is the single most important measure of a systems ability to perform low latency real-time processing of massive data amounts. The WDM Drivers WDM stands for "Windows Driver Model", and was a new driver architecture first introduced with Windows 98SE. It initially addressed many of the limitations of the older driver models. But Windows 98SE could run old style drivers as well as WDM, so almost all manufacturers kept providing the Windows 95 style drivers for it. Why make a new one if you have a working one? But Windows 2000 requires WDM drivers, it cannot run 9X style drivers. And because the mistaken idea that "Windows 2000 is not optimized for audio" was so popular, we had to wait for Windows 2000 support for a long time. Fortunately, a few audio hardware and software manufacturers, led by Cakewalk, had knowledge of the Windows 2000 potential and the impact it could have, and started the contacts and work to cooperate with Microsoft in the improvement of the WDM and DirectX functionality. Thanks to them we have soundcard WDM drivers that suit our needs, not just those of gamers and home video editors. The same WDM driver should work on Windows 98SE, 2000, XP, and probably some future OS generations. But since WDM was not mandatory in W98SE, was not tested massively in the field, and was improved in W2000, some WDM drivers designed for Windows 2000 might not run fine on W98SE. If you can't get good WDM drivers for your audio hardware, complain! WDM is the path to the best audio performance we currently have in Windows. The audio WDM driver architecture is very flexible. It exposes one or more "topologies" that inform the system how the inputs, outputs and controls are arranged, and every "pin" or connection in that topology can inform or negotiate its capabilities. This means that you can find big differences between different drivers: for example, for three different 8 channel input implementations, you can find one that presents 4 stereo pairs, other that presents 8 interleaved channels, and other than can present both. Kernel Streaming The typical interface between applications and the audio drivers goes through a common layer that handles multi-instance (so that several applications can use the same ports simultaneously), legacy support compatibility (so that older applications using the MME interface will still work), and to make it totally versatile, can mix all the incoming streams, converting sample rates and formats whenever necessary. The component that does all this magic is called KMIXER. But it has a big disadvantage when low audio latency is required: to do its stuff it needs to buffer some audio data, so that the output is delayed at least 30 ms. To overcome the latency added by KMIXER, and to provide a finer control of audio I/O, a lower interface is provided, called Kernel Streaming. It allows an application to control the drivers directly, even from kernel mode if desired, and can use a variety of audio I/O methods as convenient for the application. As you may have imagined, this was not an original idea from Microsoft but instead was championed by Cakewalk and a small team of pro audio manufacturers. So, although legacy MME still run on the new architecture, professional audio applications like DAWs should use the new KS interface to take full advantage of WDM performance. SONAR is the first application I know supporting it, and I must say that I am impressed by the performance. With WDM Kernel Streaming drivers, users can consistently playback more than 50 stereo tracks (24 bits @ 44.1 KHz) simultaneously with a latency of 3 ms without receiving a single dropout. Latency Issues "Audio output latency" refers to the maximum amount of time elapsed from the time audio data is processed to when it goes to the speakers. The minimum time that can be set without having dropouts depends on many factors: audio hardware and driver design, operating system performance, audio application design, etc. Most of them are dependent on the providers, but the operating system performance depends also on many factors. The main OS performance parameter that affects audio latency is the task scheduler latency. It is the maximum amount of time elapsed since an event is signaled until a task waiting for that event is run. And although the situation in Windows regarding this is very complex, perhaps an issue only interesting for programmers, I am going to try to make the story easy, because I consider it key to understand what is what affects latency the most in the operating system. Windows uses a clever 32 level priority scheme. The lower 16 priorities are the dynamic kind typically used by time-shared multitasking systems. All tasks with normal class priorities share the available CPU time, but more time slices are provided for tasks with higher priorities inside the normal class. The higher 16 priorities belong to the real-time class, of the kind typically used in real time systems. In the real-time class, only the highest priority task runs at a given time. Normal call priorities can only run when there is no real time task ready to run. This scheme is powerful and simple enough, since it allows the typical time-shared behavior expected for desktop computers, while strict real time requisites can be met through the use of the real time priorities. The only difference in this model compared to Unix and many other OSs is the smaller number of priority levels available (Unix, for example, uses 256 instead of 32, which offers much more flexibility), but 32 is fairly enough for all except the most complex real time projects. But real time priorities, although very convenient, can be very dangerous when used incorrectly: real time tasks using too much CPU time can lock the whole system. When there are complex dependencies among several real-time tasks, there can be lockups if the system is not well designed due to situations known as "priority inversion" where a high priority task is waiting for an event that must be satisfied by a lower priority task. In the PC world these dangers are a big issue because of the wide variety of software, and because most application programmers do not have the required knowledge to assign real time priorities. It is true that they do not need them except in very specific cases - like DAW programming, for example - but once the real time class is there, well, anyone can use it whether they need to or not. So to minimize the risk of these dangers in Windows 9x, Microsoft used a mechanism to avoid such lockups. The problem is that they did it so bad, so extremely bad, that the effect was a total violation of the "two class" model described earlier. In fact, the lowest normal priority task could often take precedence over the highest real time priority task in the system, randomly. The result was that even the highest real-time priority could be affected by a worst case latency of several hundreds of milliseconds, something totally unacceptable in real time systels. To make it worse, instead of fixing the failure, Microsoft promoted the usage of a new kind of tasks called APC (Asynchronous Procedure Calls) and DPC (Deferred Procedure Calls) to meet acceptable time requirements. These are of highest priority than anything else except interrupts, but cannot be preempted - once one starts, no other task or APC can run until it ends. Therefore they violated the perfect model described earlier. If the priority inversion avoidance mechanism worked correctly, there would not be any need for APCs, a real time priority will do it better, but the fact is that the largest, richest and most powerful company in the world apparently did not have a clue – or a care - about multitasking models. Fortunately, in Windows 2000, although there is also a priority inversion avoidance mechanism, it works flawlessly. This is one of the main reasons of Windows 2000's good performance. So, Everything is Perfect Now? Unfortunately, no. Windows 2000 is far better than Win9X, but not perfect. The APCs are still there. So even though appropriate real-time prioritization works great, many programmers learned with Win9X that "real time priorities did not work" and still use APCs mainly when developing device drivers. Microsoft should have updated the device driver development documentation explaining the convenience of using high priority tasks instead of APCs, but they did not. Intel, obviously more interested in performance issues than Microsoft, published clear information about this fact with extensive performance measurements, but that is not the source that developers study in first place. Now, why should we know about this hardly understandable story? Well, what I intended was simply to explain what remains wrong in Windows 2000: APCs are a bad thing, even if the situation is now much better than ever. And since the W2K performance monitor allows you to detect APC/DPC activity, you can find out if there are device drivers that are actually contributing to a degradation of real time performance, thus impairing your system's ability to process audio with very low latencies. In my system, for example, most device drivers are using APCs. Another reason to tell the story is that Daddy Microsoft only worries about sales. For them, a million users asking for nicer themes for their desktop makes it a big priority, while a severe problem reported by some hundred developers does not matter because it does not translate to sales very well. So the only way to have them working seriously in the operating system instead of investing 99% of the effort in the free applications they give away with the OS is to have a lot of end users that know what they want, that's all. And if you have device drivers that implement APC / DPC, then let the manufacturer of the device know that they're hurting your audio system, or choose a different device with better drivers. Anyway, I did not want to be too critical: Windows 2000 is a good operating system, no matter how bad the 9X family was. After all the crap we were using for years, we have finally something that really works well. Keep it Updated Windows 2000 has far fewer bugs than any Win9X version, but even so, there are constant fixes and improvements. Microsoft Update is an ideal way to have it up to date. Connect to it regularly. The Near Future Windows XP will be available very soon. You can think of it as the yearly update for Windows 2000. Basically, it is the same core system, but there is one detail that might be of special interest to us: some of the problems and bugs encountered during the last year of WDM audio drivers development are fixed there. And the update from Windows 2000 to XP should be very easy, not requiring reinstallation of all applications. So keep tuned! http://www.prorec.com/prorec/articles.nsf/articles/45BEB3250308114E86256A7F007D8FA4 |