Engineering Windows 7

Welcome to our blog dedicated to the engineering of Microsoft Windows 7

Continuing our discussion on performance

Continuing our discussion on performance

We've talked some about performance in this blog and recently many folks have been blogging and writing about the topic as well. We thought it would be a good time to offer some more behind the scenes views on how we have been working on and thinking about performance because it such an interesting topic for the folks reading this blog. Of course I've been using some pretty low-powered machines lately so performance is top of mind for me as well. But for fun I am writing this on my early holiday present--my new home machine is a 64-bit all-in-one desktop machine with a quad core CPU, discrete graphics, 8GB of memory, and hardware RAID all running a pretty new build of Windows 7 upgraded as soon as I finished the out of box experience. Michael Fortin and I authored this post. --Steven

Our beta isn’t even out the door yet and many are already dusting off their benchmarks and giving them a whirl. As a reminder, we are encouraging folks to hold on benchmarking our pre-production builds. Yet we’ve come to expect it will happen, and we realize it will lead many to conclude one thing or another, and at the same time we appreciate those of you who take the time to remind folks of the pre-ship status of the code. Nevertheless we’re happy that many are seeing good results thus far. We're not yet as happy as we believe we will be when we finish the product as we continue to work on all the fundamental capabilities of Windows 7 as well as all the new features folks are excited about.

Writing about performance in this blog is nearly as tricky as measuring it. As we've seen directional statements are taken further than we might intend and at the same time there are seemingly infinite ways to measure performance and just as many ways to perceive the same data. Ultimately, performance is something each individual feels is right--whether than means adequate or stellar might vary scenario to scenario, individual to individual. Some of the mail we've received has been clear about performance:

  • Boot-very very fast in all applications ( open-load applications) especially so many simultaneously!!!!! Hence, massive multicore ( quad-octa core cpu) , gpgpu for all!!!!!!!!!!!!
  • This is right time to do this properly, the users want speed, we'll give them speed.
  • i want to be able to run windows 7 extremely fast and still look good graphically on a asus aspire one netbook with these specs-1.5 ghz intel atom processor (single core) 1gb of ram
  • I hope that in addition to improvements in the gui and heart (I hope massive multicore + 64-bit + Directx 11 ..extreme performance, etc) for windows 7, modified the feature Flip 3d In Windows 7!!!!! Try to make a Flip 3D feature, really efficient and sensible in windows 7.
  • With regard to the performance thing, could you look at ways to reduce the penalty of having a lot of fonts installed.
  • From performance, boot up, explorer speed and UI experience , I hope the next version of windows delivers something new and innovating. I was playing with the new UI on the HP TouchPC and I have to say they did a great 1.0 job on the touch interface controls.
  • I do keep my fingers crossed for Windows 7 to be dramatically better in its performance than Windows Vista.
  • The biggest feature I see a lot of people wanting is performance.

You can also see through some of these quotes that performance means something different to different people. As user-interface folks know, perceived performance and actual performance can often be different things. I [Steven] remember when I was writing a portion of the Windows UI for Visual C++ and when I benchmarked against Borland C++ at the time, we were definitely faster (measured by seconds). However the reviews consistently mentioned Borland as being faster and providing feedback in the form of counts of lines compiled flying by. So I coded up a line count display that flashed a lot of numbers at you while compiling (literally flashy so it looked like it couldn't keep up). In clock times it actually consumed a non-zero amount of time so we got "slower" but the reviewers then started giving us credit for being faster. So in this case slower actually got faster.

There's another story from the past that is the flip side of this which is the scrolling speed in Microsoft Word for DOS (and also Excel for Windows--same dynamic). BillG always pushed hard on visible performance in the "early" days and scrolling speed was one of those things that never seemed to be fast enough. Well clever folks worked hard on the problem and subsequently made scrolling too fast--literally to the point that we had to slow it down so you didn't always end up going from page 1 to the end of the document just because you hold down the page down key. It is great to be fast, but sometimes there is "too much speed".

We have seen the feedback about what to turn off or adjust for better performance. In many ways what we're seeing are folks hoping to find the things that cause the performance to be less than they would like. I had an email conversation with someone recently trying to pinpoint the performance issues on a new laptop. Just by talking through it became clear the laptop was pretty "clean" (~40 processes, half the 1GB of RAM free, <5% CPU at idle, etc.) and after a few back and forths it became clear it was the internet connection (dial-up) that was actually the biggest bottleneck in the system. Many encourage us to turn off animations, graphics, or even color as there is a belief that these can be the root of performance. We've talked about the registry, disk space utilization, and even color depth as topics where folks see these as potential performance issues.

It is important to consider that performance is inherently a time/space tradeoff (computer science sense, not science fiction sense), and on laptops there is the added dimension of power consumption (or CPU utilization). Given infinite memory, of course many algorithms would be very different than the ones we use. In finite memory, performance is impacted greatly by the overall working set of a scenario. So in many cases when we talk about performance we are just as much talking about reducing the amount of memory consumed as we are talking about the clock time. Some parts of the OS are much more tunable in terms of the memory they use, which then improves the overall performance of the system (because there is less paging). Other parts of the system are much more about the number of instructions executed (because perhaps every operation goes through that code path). We work a great deal on both!

The reality of measuring and improving performance is one where we are focused at several "levels" in Windows 7: micro-benchmarks, specific scenarios, system tuning. Each of these plays a critical role in how we are engineering Windows 7 and while any single one can be measured it is not the case that one can easily conclude the performance of the system from a measurement.

Micro-benchmarks. Micro-benchmarks are the sort of tests that stress a specific subsystem at extreme levels. Often these are areas of the code that are hard to see the performance of during usage as they go by very fast or account for a small percentage of time during overall execution. So tests are designed to stress part of the system. Many parts of the system are subjected to micro-benchmarking such as the file system, networking, memory management, 2D and 3D graphics, etc. A good example here is the work we do to enable fast file copying. There is a lot of low level code that accounts for a (very significant) number of conditions when copying files around, and that code is most directly executed through XCOPY in a command window (or an API). Of course the majority of copy operations take place through the explorer and along with that comes a progress indicator, cancellable operation, counting up bytes to copy, etc. All of those have some cost with the benefit as well. The goal of micro-benchmarks is to enable us to best understand the best possible case and then compare it to the most usable case. Advanced folks always have access to the command line for more power, control, and flexibility. It is tempting to measure the performance of the system by looking at improvements in micro-benchmarks, but time and time again this proves to be inadequate as routine usage covers a much broader code path and time is spent in many places. For Internet Explorer 8 we did a blog post on performance that went into this type issue relative to script performance. At the other end of the spectrum we definitely understand the performance of micro-benchmarks on some subsystems will be, and should be, carefully measured --the performance of directx graphics is an area that gamers rely on for example. It is worth noting that many micro-benchmarks also depend heavily on a combination of Windows OS, hardware, and specific drivers.

Specific scenarios. Most people experience the performance of a PC through high level actions such as booting, standby/resume, launching common applications. These are topics we have covered in previous posts to some degree. In Engineering Windows 7, each team has focused on a set of specific scenarios that are ones we wanted to make better. This type of the work should be demonstrable without any elaborate setup or additional tools. This work often involves tuning the code path for the number of instructions executed, looking at the data allocated for the common case, or understanding all the OS APIs called (for example registry lookups). One example that comes to mind is the work that we have going on to reduce the time to reinsert a USB device. This is particularly noticeable for UFD (USB flash drives) or memory cards. Windows of course allows the whole subsystem to be plumbed by unique drivers for a specific card reader or UFD, even if most of the time they are the same we still have to account for the variety in the ecosystem. At the start of the project we looked at a full profile of the code executed when inserting a UFD and worked this scenario end-to-end. Then systematically each of the "hot spots" was worked through. Another example along these lines was playback of DVD movies which involves not only the storage subsystem but the graphics subsystem as well. The neat thing about this scenario is that you also want to optimize for the CPU utilization (which you might not even notice while playing back the movie) as that dictates the power consumption.

System tuning. A significant amount of performance work falls under the umbrella of system tuning. To ascertain what work we do in this area we routinely look at the overall performance of the system relative to the same tests on previous builds and previous releases of Windows. We're looking for things that we can do to remove operations that take a lot of time/space/power or things that have "grown" in one of those dimensions. We have build-to-build testing we do to make sure we do not regress and of course every developer is responsible for making sure their area improves as well. We left no stone unturned in terms of investigating opportunities to improve. One of the areas many will notice immediately when looking at the pre-beta or beta of Windows 7 is the memory usage (as measured by task manager, itself a measurement that can be misunderstood) of the desktop window manager. For Windows 7, a substantial amount of architectural work went into reducing the amount of memory consumed by the subsystem. We did this work while also maintaining compatibility with the Windows Vista drivers. We did similar work on the desktop search engine where we reduced not just the memory footprint, but the I/O footprint as well. One the most complex areas to work on was the improvements in the taskbar and start menu. These improvements involved substantial work on critical sections ("blocking" areas of the code), registry I/O, as well as overall code paths. The goal of this work is to make sure these UI elements are always available and feel snappy.

It is worth noting that there are broad based measures of performance as well that drive the user interface of a selection of applications. These too have their place--they are best used to compare different underlying hardware or drivers with the same version of Windows. The reason for this is that automation itself is often version dependent and because automation happens in a less than natural manner, there can be a tendency to measure these variances rather than any actual perceptible performance changes. The classic example is the code path for drawing a menu drop down--adding some instructions that might make the menu more accessible or more appealing would be impossible to perceive by a human, but an automated system that drives the menu at super human speed would see a change in "performance". In this type of situation the effect of a micro-benchmark is magnified in a manner inconsistent with actual usage patterns. This is just a word of caution on how to consider such measurements.

Given this focus across different types of measurement it is important to understand that the overall goal we have for Windows 7 is for you to experience a system that is as good as you expect it to be. The perception of performance is just as important as specific benchmarks and so we have to look to a broad set of tools as above to make sure we are operating with a complete picture of performance.

In addition to these broad strategies there are some specific tools we've put in place. One of these tools, PerfTrack, takes the role of data to the next level with regard to performance and so will play a significant role in the beta. In addition, it is worth reminding folks about the broad set of efforts that go into engineering for performance:

  • We’ve been building out and maintaining a series of runs that measure thousands of little and big things. We’ve been running these before developer check-ins and maintaining performance and responsiveness at a level above which all that self-host our builds will find acceptable. These gates have kept the performance and responsiveness of our daily builds at a high enough level that thousands have found it possible to run their main systems on Windows 7 for extended periods of time, doing their normal daily work.
  • We’ve been driving down footprint, reducing our service costs, improving the efficiency of key code paths, refactoring locks to improve scalability, reducing hangs, improving our I/O efficiency and much more. These are scenario driven based on real world execution paths we know from our telemetry to be common.
  • We’ve been partnering closely with the top OEMs, ISVs and IHVs. Our tools have been made public, we’ve held numerous training sessions, and we’ve been focusing heavily on shipping systems in an effort to insure customers get great performing systems out of the box, with great battery life too.
  • Within the Windows dev team, we’ve placed a simple trace capturing tool on everyone’s desktop. This desktop tool allows each person to run 24x7 with performance tracing enabled. If anything seems slow or sluggish, they can immediately save the last minute-or-so of activity and send it for automated analysis. Additionally, a team of people visually inspect the traces for new issues or issues not yet decipherable by our automation. The traces are incredibly rich and allow us to get to the root of top issues most of the time.
  • For all Pre-Beta, Beta and RTM users, we’ve developed a new form of instrumentation and have used it to instrument over 500 locations in the operating system and inbox applications. This new instrumentation is simple in concept, but revolutionary in result. The tool is called PerfTrack, and it has helped confirm our belief that the client benchmarks aren’t too informative about real user responsiveness issues.

Perftrack is a very flexible, low overhead, dynamically configurable telemetry system. For key scenarios throughout Windows 7, there exist “Start” and “Stop” events that bracket the scenario. Scenarios can be pretty much anything; including common things like opening a file, browsing to a web page, opening the control panel, searching for a document, or booting the computer. Again, there are over 500 instrumented scenarios in Windows 7 for Beta.

Obviously, the time between the Stop and Start events is meant to represent the responsiveness of the scenario and clearly we’re using our telemetry infrastructure to send these metrics back to us for analysis. Perftrack’s uniqueness comes not just from what it measure but from the ability to go beyond just observing the occurrence of problematic response times. Perftrack allows us to “dial up” requests for more information, in the form of traces.

Let’s consider the distribution below and, for fun, let's pretend the scenario is opening XYZ. For this scenario, the feature team chose to set some goals for responsiveness. With their chosen goals, green depicts times they considered acceptable, yellow represents times they deemed marginal, and red denotes the poor times. The times are in milliseconds and shown along the X axis. The Hit Count is shown on the Y axis.

Graph measuring responsiveness goals and real world data.

As can be seen, there are many instances where this scenario took more than 5 seconds to complete. With this kind of a distribution, the performance team would recommend that we “dial up” a request for 100+ traces from systems that have experienced a lengthy open in the past. In our “dialed up” request, we would set a “threshold” time that we thought was interesting. Additionally, we we may opt to filter on machines with a certain amount of RAM, a certain class of processor, the presence of specific driver, or any number of other things. Clients meeting the criteria would then, upon hitting the “Start” event, configure and enable tracing quickly and potentially send back to us if the “Stop” event occurred after our specified “threshold” of time.

As you might imagine, a good deal of engineering work went into making this end to end telemetry and feedback system work. Teams all across the Windows division have contributed to make this system a reality and I can assure you we’ll never approach performance the same now that we have these capabilities.

As a result of focusing on traces and fixing the very real issue revealed by them, we’ve seen significant improvements in actual responsiveness and have received numerous accolades on Windows 7. Additionally, I’d like to point out that these traces have served to further confirm what we’ve long believed t be the case.

This post provides an overview of the ways we have thought about performance with some specifics about how we measure it throughout the engineering of Windows 7. We believe that throughout the beta we will continue to have great telemetry to help make sure we are achieving our goals and that people perceive Windows 7 to perform well relative to their expectations.

We know many folks will continue to use stop watches, micro-benchmarks, or to drive automated tests. These each have their place in your own analysis and also in our engineering. We thought given all the interest we would talk more about how we measure things and how we're engineering the product.

--Steven and Michael

Leave a Comment
  • Please add 6 and 7 and type the answer here:
  • Post
  • If all this work will result in some tool that tells me what Windows is doing when its busy, that's a good thing. I dont even know of a third party app that will do this. Sure there are plenty of apps that will tell you what you can already find out with WMI, but I'm interested in whether its disk, network, or other resource that its waiting for, not which process is busy in the tasks list.

  • @Jandler

    Send this to Randall

    http://www.pcmag.com/article2/0,2817,2337045,00.asp

  • in response to Jestempies request for a better taskmgr, the resource monitor in Windows7 was improved significantly over the Vista version.  it is linked to conveniently from the taskmgr, and offers many substantial improvements.  My team and I look forward to hearing feedback on it.

    It does not, unfortunately address your specific notes on network i/o scaling.  The scale is still shown relative to the local connections.

  • Now with latest Windows 7 builds looking much better then Vista in performance area, there's still one small bug left inside it.

    It's interesting to note that this bug, no, feature is most resource intensive according to task manager in the matter of disk I/O, open file handles, etc... Guess what it is?

    Windows Defender! Do you guys consider malware to be essential part of Windows ecosystem? What's the point of silently scanning my system so often? Sorry, but to be honest - it has never ever been useful in XP or Vista.

    And it looks so alien and shallow... Can you at least make it uninstallable?

  • What about trying to reduce the polling done by Explorer and the various services.

    To see what I mean: download Process Monitor, close all of your programs and run it. In a few seconds you'll see thousands of disk and registry accesses. Even if done from lower priority threads, they can still affect the responsiveness and things like laptop battery life.

    It's sad that this issue seems have aggravated in every version of Windows, including the pre-betas.

  • One aspect of performance that is often overlooked is executable size. When Windows starts, the size of the things it has to load is rather large. The astonishing thing is how much of this size is just waste. Even the most basic start up code from the Visual C++ CRT is bigger than it needs to be. This casual attitude--often caused by a "the compiler will optimize it" spreads throughout the entire package from top to bottom. A bit of bloat in everything pretty soon adds up to a gargantuan amount.

    * * *

    Another poster made a very good point about pieces of windows doing a lot of polling. Just run regmon and the number of useless reads and writes to the registry will blow your mind. It gets worse from there; looking at raw disk access.

    * * *

    The point of both of these is that Microsoft engineers could gleen a whole lot of performance gain in windows and other products by a bit more engineering discipline--heck just giving an honest answer to the question "do I really need to do that?" would give great gains.

  • This is the corollary to the componentisation post,isn't it ;-)

    Personally, I notice I'm reluctant to switch back from my W7 test machine to the many other PCs I need to use that aren't running 7 ;-) Performance-wise, what feels fastest isn't anything that's actually to do with actual performance: it's getting at documents through Libraries. The file open and browse time is probably identical to Vista, but I get my document faster because it's more logical and easier to find.

    I have noticed - and I think it says how good M3 is that it took me a while to accept - that when things start getting unstable (Excel tells me there's not enough memory to start even though I have 50% free memory, IE8 doesn't paint a whole page properly, etc) that I should reboot instead of hoping for the system to stabilise. Personally, I like to reboot about every 6 months when I really feel I need updates (do I hear the security team screaming?): the rest of the time I just hibernate. At the moment, I am rebooting a fraction more often than in Vista and I think that's another performance/time calculation: how performance changes over the time of a Windows 'session'.

  • joewoodbury: AFAIK The whole executable doesn't get loaded into RAM.

  • joewoodbury: AFAIK The whole executable doesn't get loaded into RAM until needed, certain parts can be paged out when not in use.

  • In response to GrayShade's comments on polling and disk and registry accesses, we have been and still are quite focused on these matters.

    We've come quite a long way during the release of Windows7 and have been working more and more w/ our partners on the applications and services typically installed on client systems.  

    At PDC, a nice talk was given on the tools we use internally and w/ partners to root out these issues.  A channel9 video of the talk is available here http://channel9.msdn.com/pdc2008/PC62-V/    The portion of the talk that focuses on energy efficiency is most relevant.

    We know this is quite important and we're committed to continuing our efforts to reduce these activities.

    Thanks   Michael Fortin

  • manicmarc: Unfortunately, this attitude and ignorance is the root of this problem. While Windows does paging, it's not as simple as paging happily away and, most importantly, larger programs use more pages and cause more page faults which are very expensive performance wise. (I wrote some code years ago where a simple, small algorithm was inexplicably faster in real usage than than the larger, more complex one until we looked at page faults and the answer became clear.)

    I can't count the times I've seen DLL initialization code hit enough pages throughout the DLL image that it effectively loads all the pages. Or code that is so large and complex that it crosses page boundaries. Few programmers pay attention to this. Even few pay attention to base address, which can greatly improve load times. (And the number of .NET developers that don't pay attention to File Alignment is huge.)

    Finally, larger images reserve larger amounts of memory which exacts a real performance cost (yes, small in isolation, but it adds up.)

    (PS. To be fair; Microsoft does do a better job than most in what I'm discussing, I just think they can do better.)

  • I frequently hear of Windows performance tips from supposed experts that don't always seem correct e.g. turning off Aero/SuperFetch/Search/etc. Of course, maybe their tips are valid in certain situations (e.g. no hardware graphics accelerator, constrained memory, etc.), but may not be valid in others.

    Can you provide benchmarking software that can validate these generalized statements, or better yet, document when certain features of Windows is better turned off for performance reasons so that all the ambiguity is removed.

  • Hello

    just one thing about peformance in Windows, in Windows Vista you add Windows Defender for more Security. Windows Defender most is not important, becouse the user will install an other security software(Norton, Avira Premium, Spybot ot others...), so please remove Windows Defender and ad him to the Live Apps, or let him away(i hear OneCare will be a Live app soon)...Defender creates a lot of Disk I/O and use performance, but most Users dont need him...

  • once again:

    Applications can write things to system directory. It's bigger and reading it needs more and more time. It was required adding protecting system files, System Restore, WinSXS and similar solutions. They're working, but naturally need some RAM, CPU time and HDD space. Isn't better to close access to system directory and decrease number of these checks ?

    There were many methods of breaking Windows security, because applications were working with high privileges. The answer is Windows Defender. It needs some RAM, CPU time and HDD space. Isn't better to separate more processes and make it unnecessary ?

    There were many performance issues with Vista. The answer is building more checks in system. It needs some RAM, CPU time and HDD space....

    And what about DRM checks. How much they affect system ?

    As said before, start from roots and later add additional things to them. Don't put Ferrari on old car chassis, but start from better chassis.

    If you will allow manufacturers of drivers making strange things (like adding some applications on startup, which later work in the tray), they will do it... The same with Registry - if it's shared, you will always have problems, etc. etc.

  • @Domenico,

    I wasn't aware of the 10.5.6 issues as I use OS-X in a virtual environment at my brother's PC and we don't use the most current builds. I try to keep in practice of Apple's OS but I don't use it on a daily basis. I prefer Windows to Mac OS-X, because I prefer the hardware and software environment. Second, I cannot justify a $1,200 for non-desktop CPU.

    However, we cannot as users, designers, or developers become complacent because of Apple's problems. When Apple's operating system works, its performance is beating Vista and XP. Startup, shutdown, and performance over time. Just because Apple users are having problems now, we had problems at launch with file copy with Vista. While Mac fanatics may have an blind devotion to all things Apple, Windows users need to be bound in truth.

    We as Windows users must always be looking to better performance. Thats is why I'm continuing to blog here that Windows 7 must be the best it possibly can be. It must break the trend of poor performance over time. It must speed up the OS and bring a "Wow" factor that was missing in Vista.

    I really do appreciate your post and encourage as you clearly know what you're talking about.

    Peace.

Page 5 of 9 (129 items) «34567»