DevX Home    Premier Club    Search    Help    Locator+    Shop DevX    





 
Performance Enhancements in Windows® XP

By Andrew Binstock

Introduction

During the last several years, Microsoft® has upgraded a major version of Windows every year. Windows 98, Windows 4.0, Windows ME, Windows 2000, and now Windows XP. Between these releases, there appeared service packs to apply and decisions about whether to configure PCs as NT-based workstations or Windows 9x descendants of MS-DOS.

The goals of these constant updates and upgrades were two-fold. The first and most conspicuous was the addition of substantial new functionality, such as Active Directory, which appeared in Windows 2000. The second—and more important—goal has been the quest for reliability. The release of Windows 2000 is the first release of any Microsoft operating system that can be called reliable with a straight face and a clear conscience. This new level of reliability means you do not have to reboot much—not more frequently than once or twice a month. This might not be mission-critical reliability, but it's a darn sight closer than Microsoft has ever been before.

Having attained this kind of solidity and having parried any last remaining challenge from Novell with the delivery last year of Active Directory, Microsoft is suddenly free to consider what it wants to do in its head-to-head competition with UNIX (and Linux, by extension). With the upcoming release of Windows XP, Microsoft has made it clear it wants to set off in its own direction. Specifically, it wants to provide its own innovations without having to worry about whether it's responding to the UNIX gang.

As a result, several interesting features have been introduced in Windows XP. The most conspicuous of these, of course, is the complete absence of Java. Microsoft has announced there will be no JVM shipped with Windows XP. Separately, the company has redone the user interface (again!) and removed all icons. The first step got Microsoft out of any entanglements with Sun regarding the residual terms of the Java lawsuit settlement; the second move was a response to the antimonopolists at the Department of Justice.

But the real news is not Java or the absence of icons, but the unique performance enhancements Microsoft has made in Windows XP.

Running Faster

The performance optimizations appear in three separate areas: application loading, system boot, and hardware management. Of these, applications loading is the most interesting and the one developers will have to think about the most.

Application Loading

Prior to Windows XP, applications have loaded basically the same way on all operating systems: At launch, the application's main module is loaded into memory, then the DLLs used by this module are loaded. Address resolution is performed by the loader, and the application starts up. During startup, the program is likely to examine the registry or read data from a configuration file. Once all this is done, the application continues bootup and eventually begins its intended operations. As every user knows, this process generates hundreds of disk seeks. And the only way the number of seeks can be reduced is if portions of the application are already in cache and read from there into the program's process space. Otherwise, a disk seek is needed.

With Windows XP, Microsoft has changed the process. The operating system keeps a log of which files are needed at application start up and which data files are typically used (for example, a certain spreadsheet that is regularly used when Excel is booted). When the app is started, Windows XP looks at this list of files and seeks all of them at once. In so doing, it can consolidate disk seeks optimally and reduce head movement. So rather than thrashing the disk, application launch process now minimizes disk seeks.

To enhance this process further, Windows XP will moves the files around on your disk during lulls in computing activity. For example, it will reposition all files used in starting up your favorite browser and place them in contiguous blocks on the disk. This way, in just a few disk seeks, the entire application can be loaded. And to reduce head seeks even more, it places these blocks as much as possible on the outermost sectors of the disk, so that the heads have to travel as little as possible.

How does it know which files to move? Windows XP keeps track of files used by every application. After several launches of the same application, it has some sense of what files are required. Thereafter, it uses an algorithm that says, basically, if a file has not been used in the last six launches, it is marked for removal; if a file has been used in the last two launches, it's marked for inclusion. Then based on these notations, Windows XP determines which files need to be brought into the block, and which ones moved out. When this move will take place depends on several factors, such as how recently files were moved for this application, and when the machine is available? Consistent with the idea that disk activity should not interfere with performance, Windows XP won't move the application files unless there has been no user-initiated I/O activity for 13 minutes. Microsoft presumes this means the user is away from the machine. It then begins migrating the files to the optimal place on the disk.

This innovation has implications for developers. Previously, the recommendation was to write small DLLs that could load quickly. But now, such small DLLs are loaded into memory only when called, and are thus likely to cause delays. With fast app loading, therefore, developers really want to stuff their programs into a few large DLLs, so the DLLs will always be loaded when the application is launched.

Fast Boot

Windows XP uses a technique similar to application-launch optimization to arrange boot-up files as efficiently as possible, especially files used by the operating system. But Microsoft has also added several other features of importance.

The first of these is parallelism in device querying. In previous Windows releases, the boot cycle queried numerous devices and waited for their reply before continuing. Only once the full complement of hardware was known would the boot continue. Windows XP first determines whether the OS can load. If it can, it begins to load while the devices are being queried. As results from the queried devices are generated, the data is folded into the boot process. Hence, the usual blocking caused by synchronous device queries has been sidestepped.

Network authentication, of course, is the ultimate blocking query. To get around it, Windows XP can be configured to use cached credentials. Through this trick, the user can be logged on to the single machine and begin working locally. However, the OS will halt if any network request is made and formal authentication has not verified the credentials.

Undoubtedly, security issues will have to be considered when using this last feature. But for users with laptops, this is a valuable option.

Resume from Standby

Laptops have two battery-conservation modes: Standby, in which the screen is dimmed and system activity is reduced; and hibernation, in which system memory is written to disk and the disk is halted. Resuming from hibernation requires the disk to start up and all applications to be reloaded from disk to memory. This is a long cycle akin to boot up. Microsoft has optimized aspects of the hibernate by improving the memory-save function. But in resume-from-standby, Windows XP uses the same parallelism of device query seen in the standard boot-up phase. Formerly, devices were sequentially and synchronously notified of the change in power state. With Windows XP, the notifications run in parallel and the wait for response does not delay the start-up cycle. Resuming from standby now can happen in as little as two seconds.

Hardware Changes

The biggest change in hardware support is Windows XP's significant benchmarking of a system's video driver. Because the new Windows XP user interface relies even more heavily on graphical effects, slow or poorly written graphical device drivers will appreciably affect performance. Hence, Microsoft tests graphical drivers. And in its default state, it will disable effects that take too much time. Typical disabled effects are menu-fading, and shadowing. For developers, this means that some applications might look slightly different on older machines with slower graphics subsystems or drivers. Users can override the disabling of these affects, at the cost of slower performance.

The last hardware change of note is that Windows XP will automatically perform disk defragmentation during activity lulls. As described previously, these lulls consist of 13 minutes of no user I/O. The result of this is, of course, more-efficient disk access.

What Have They Wrought?

Microsoft correctly understood that to improve performance, it could no longer simply exhort users to buy faster CPUs and more memory. It had to tackle the issue itself. It did this by focusing on the biggest known bottleneck: disk I/O. By managing file location, performing optimized reads, and constantly defragmenting the disk, Microsoft has made sure that its operating system gets the best possible I/O from the disk.

Competing operating systems do not do this yet. Nor do they optimize boot-up the way Windows XP does. For the first time, Microsoft has jumped out ahead of its competitors in terms of useful operating system innovations. If it keep this up, we're going to see operating systems get a lot better pretty quickly. It will be about time.

Andrew Binstock is the principal analyst at Pacific Data Works LLC, a firm that specializes in high-tech white papers. He is a frequent contributor to DevX.com. He can be reached at abinstock@pacificdataworks.com.

We welcome your reactions to this article in the Performance & Reliability Discussion folder.



 

Sign up for our Windows XP email newsletter and we'll send you regular updates.

Microsoft Windows XP: What's in It for Developers?
What's New in the Shell
How to Write a
Windows XP Driver

Official Microsoft Windows XP Site
Overview of SOAP Client in Windows XP
Windows XP-Ready PCs from Compaq
Windows XP Home and Professional Editions: The SuperSite Review (by Paul Thurrott)
Windows XP FAQ (from ActiveWin)
CNET Windows XP Superguide
.NET Zone
Get Started With WinForms
C++ Zone