August, 2005

  • The Old New Thing

    How many floppy disks did Windows 95 come on?



    In case you were wondering.

    And those were thirteen of those special Distribution Media Format floppies, which are specially formatted to hold more data than a normal 1.44MB floppy disc. The high-capacity floppies reduced the floppy count by two, which resulted in a tremendous savings in cost of manufacturing and shipping.

    (I'm sure there are the conspiracy-minded folks who think that DMF was invented as an anti-piracy measure. It wasn't; it was a way to reduce the number of floppy disks. That the disks were difficult to copy was a side-effect, not a design goal.)

    (For comparison, Windows 3.1 came on six floppies. Windows NT 3.1 came on twenty-two. And yesterday, one of my colleagues reminded me that Windows NT setup asked for the floppy disks out of order! I guess it never occurred to them that they could renumber the disks.)

  • The Old New Thing

    Why is Windows Error Reporting nicknamed "Dr. Watson"?


    The nickname for the feature known as Windows Error Reporting is "Dr. Watson". Where did that name come from?

    As you have probably guessed, The name Dr. Watson was inspired by the character of Dr. Watson, the assistant to Sherlock Holmes in the stories by Arthur Conan Doyle.

    It is my understanding that the doctor was originally developed as part of Windows 3.0 beta testing. His job was to record data about application crashes to a file, so that the file could be uploaded and included with bug reports. The icon was (and continues to be) a friendly doctor using his stethoscope to investigate a problem.

    The Doctor has remained true to the "capture information about an error" aspect of his job. In the meantime, the word "Watson" has expanded its meaning to encompass anonymous end-user feedback mechanisms in general, such as "Content Watson". (But if you hear "Watson" by itself, the speaker is almost certainly talking about error reporting.)

  • The Old New Thing

    Buying an entire Egghead Software store


    During the development of Windows 95 (which released to the public ten years ago today), application compatibility was of course a very high priority. To make sure that coverage was as broad as possible, the development manager for Windows 95 took his pick-up truck, drove down to the local Egghead Software store (back when Egghead still existed), and bought one copy of every single PC program in the store.

    He then returned to Microsoft, unloaded all the software onto tables in the cafeteria, and invited every member of the Windows 95 team to come in and take responsibility for up to two programs. The ground rules were that you had to install and run the program, use it like a normal end user, and file a bug against everything that doesn't work right, even the minor stuff. (Of course, you had to provide the program to the person investigating the bug upon request.) In exchange for taking responsibility for ensuring that Windows 95 was compatible with your adopted programs, you got to keep them after Windows 95 shipped. If you did a good job with your two, you could come back for more.

    The cafeteria was filled with Windows 95 team members, browsing through the boxes upon boxes of software like bargain-hunters at a flea market. And there were the inevitable "What'd you get?" comparisons afterwards.

    I picked up only one program, an English/German automatic translator. It ran fine but produced pretty bad translations. (Not that the quality of the translations was in any way the fault of Windows!)

  • The Old New Thing

    How do you convince developers to pay their "taxes"?


    The Tablet PC team have a tough task ahead of them at this year's PDC: They have to get people to care about power management.

    The reason why this is tough is that power management is rarely a deal-maker. If a user is evaluating, say, personal finance software, how much weight are they going to place on which program consumes less battery power? That's probably a third- or fourth-level tiebreaker. No amount of power management is going to overcome the fact that your program's interface is harder to use than your competitor's. Nobody ever said, "Oh, yeah, I switched my word processor from X to Y because X was chewing too much battery power." When a battery doesn't last very long, users tend to blame the battery, not the software that is draining it.

    Power management falls into a category some development teams call "taxes". It's something you do, not because it actually benefits you specifically, but because it benefits the software landscape as a whole. Other taxes include making sure your program plays friendly with roaming user profiles, Fast User Switching, Hierarchical Storage Management, multiple monitors, Remote Desktop, and 64-bit Windows.

    Of course, not all development teams in the world are so diligent as to pay all their "taxes". I suspect most cheat on their taxes, and some of them just don't pay any at all.

    So here's my question to you: How do you convince developers to pay their "taxes"? (Should developers have to pay taxes at all?)

  • The Old New Thing

    When people ask for security holes as features: Silent install of uncertified drivers


    Probably the single greatest source of bluescreen crashes in Windows XP is buggy device drivers. Since drivers run in kernel mode, there is no higher authority checking what they're doing. If some user-mode code runs amok and corrupts memory, it's just corrupting its own memory. The process eventually crashes, but the system stays up. On the other hand, if a driver runs amok and corrupts memory, it's corrupting your system and eventually your machine dies.

    In acknowledgement of the importance of having high-quality drivers, Windows XP warns you when an uncertified driver is being installed. Which leads to today's topic, a question from a device driver author.

    When I try to install any driver, I get a User Consent Dialog box which tells the user that this is an unsigned driver. Is it possible to author a driver installation package that by-passes this user consent dialog box?

    The whole purpose of that dialog is to prevent the situation you desire from happening! [typo fixed 5pm] If you don't want the warning dialog, submit your driver for certification. (For testing purposes, you can sign your drivers with the test root certificate and install the test root certificate before running your setup program. Of course, installing the test root certificate also causes the desktop to read "For test purposes only" as a reminder that your machine is now allowing test-signed drivers to be installed.)

    Driver writers, of course, find the certification process cumbersome and will do whatever they can to avoid it. Because, of course, if you submit your driver for certification, it might fail! This has led to varying degrees of shenanigans to trick the WHQL team into certifying a driver different from the one you intend to use. My favorite stunt was related to my by a colleague who was installing a video card driver whose setup program displayed a dialog that read, roughly, "After clicking OK, do not touch your keyboard or mouse while we prepare your system." After you click OK, the setup program proceeds to move the mouse programmatically all over the screen, opening the Display control panel, clicking on the Advanced button, clicking through various other configuration dialogs, a flurry of activity for what seems like a half a minute. When faced with a setup program that does this, your natural reaction is to scream, "Aaaiiiiigh!"

  • The Old New Thing

    The poor man's way of identifying memory leaks


    There is a variety of tools available for identifying resource leaks, but there's one method that requires no tools or special compiler switches or support libraries: Just let the leak continue until the source becomes blatantly obvious.

    Nightly automated stress testing is a regular part of any project. Some teams use screen savers as the trigger, others use a custom program, still others require manual launching of the stress test, but by whatever means, after you've gone home for the day, your computer connects to a central server and receives a set of tests that it runs all night.

    One of the things that these overnight tests often turn up are memory leaks of one sort or another, identified by the stress team because your program's resource usage has gone abnormally high. But how do you debug these failures? These machines aren't running a special instrumented build with your leak detection tool, so you can't use that.

    Instead, you use the "target-rich environment" principle.

    Suppose you're leaking memory. After fifteen hours of continuous heavy usage, your program starts getting out-of-memory failures. You're obviously leaking something, but what?

    Think about it: If you are leaking something, then there are going to be a lot of them. Whereas things you aren't leaking will be few in number. Therefore, if you grab something at random, it will most likely be a leaked object! In mathematical terms, suppose your program's normal memory usage is 15 megabytes, but for some reason you've used up 1693 megabytes of dynamically-allocated memory. Since only 15 megabytes of that is normal memory usage, the other 1678 megabytes must be the leaked data. If you dump a random address from the heap, you have a greater-than-99% chance of dumping a leaked object.

    So grab a dozen or so addresses at random and dump them. Odds are you'll see the same data pattern over and over again. That's your leak. If it's a C++ object with virtual methods, dumping the vtable will quickly identify what type of object it is. If it's a POD type, you can usually identify what it is by looking for string buffers or pointers to other data.

    Your mileage may vary, but I've found it to be an enormously successful technique. Think of it as applied psychic powers.

  • The Old New Thing

    How can a company get access to Windows Error Reporting data?


    What happens to all the crashes in programs not written by Microsoft that are submitted via Windows Error Reporting? Microsoft still collects and indexes them, and vendors can sign up to gain access to the error reporting database to see the crashes in their programs. The service is free, although it does require a Verisign ID so that the Winqual system can confirm that you are who you claim you are. (It would be bad if somebody could pretend to be, say, Adobe, and get all their crash data.)

    There will be a session at the PDC which will go into how you the software developer can take advantage of all this data in order to improve your product from pre-release through general availability and even into sustained engineering.

    Windows Vista: Improving your Products Code Quality through Windows Feedback Services

    Your customers are sharing their pain and product experiences with you. Are you listening? Learn how to use the updated automated feedback mechanisms in Windows to gather, view and act upon customer Feedback data. Windows Feedback data will enable you to improve quality early in your product cycle, prioritize work and fix problems your users are encountering on a daily basis; even lower your support costs while increasing customer satisfaction and reliability of your applications.

    Yes, it's a kind of boring title. The original title was "Turning dissatisfied customers into gold". I would've used something like "Your program is crashing. Are you listening?" Oh well, the title isn't important. What's important is that you can use this information to make your products better.

  • The Old New Thing

    A ticket to the Windows 95 launch


    A limited number of seats at the Windows 95 launch were available to the product team, so there was a lottery to see who would get one of those tickets. The remainder of the team would be standing on bleachers hidden behind the stage, to be unveiled at the grand climax of the product launch festivities.

    I happened to have been a winner in the ticket lottery, but the fact that there weren't enough seats for everybody created some degree of grousing among the have-nots. As a show of solidarity, I forewent the special VIP pass and ticket, instead taking my place in the crowd of red, blue, yellow, and green T-shirts waiting backstage and giving the pass and ticket to a colleague who really wanted to be in the tent.

    While I waited in the staging room to be positioned for the grand finale, I was somewhat surprised to see my colleague in the room with me. She gave me back my unused VIP pass and ticket, saying, "It didn't feel right being out there in the tent. This is where I belong."

    I probably have the only unused ticket to the Windows 95 launch.

    While standing on the bleachers behind the screen, we could hear everything going on. When Jay Leno disappeared backstage to head off to his next scene, he emerged between the two sets of bleachers. We silently waved at him, but he was obviously focused on his job and didn't have time to schmooze with us.

    It was very hard staying quiet for so long backstage. Our presence was supposed to be a surprise; any noise would give us away. There were moments where whispers got out of hand and people had to wave frantically (or—heavens—shush!) to restore quiet. I thought for certain one of our out-of-control moments had let the cat out of the bag, but from talking to people afterwards who were in the tent, I learned that nobody noticed a thing.

    Our only instructions from the director were "Wave, clap, and cheer!", keeping up the energy until the last of the crowd had filed out. Everything beyond that was improvised. Somebody started up a cheer, with half of the bleachers shouting "Windows!" and the other half responding "95!" I'm sure there were other things we did to maintain the excitement, though I can't remember any of it now. I just remember that after a while I got tired of smiling and clapping but kept it up because I was on the aisle next to all the attendees, and that's show business!

  • The Old New Thing

    This might be for real, even though it comes out at 7am


    One of our researchers IM'd me yesterday to let me know that someone she interviewed mentioned that some people suspected that I wasn't real because most of my posts are published at the same time every day.

    I dunno. The evening news comes on at the same time every day, but I'm pretty sure they're real. Maybe I should be more suspicious.

    If I were real.

  • The Old New Thing

    Why does the Internet Explorer animated logo arrange its frame vertically?


    If you ever tried to build a custom animated logo for Internet Explorer, you cetainly noticed that the frames of the animation are arranged vertically rather than horizontally. Why is that?

    Because it's much more efficient.

    Recall that bitmaps are stored as a series of rows of pixels. In other words, if you number the pixels of a bitmap like this:


    then the pixels are stored in memory in the order 123456789. (Note: I'm assuming a top-down bitmap, but the same principle applies to bottom-up bitmaps.) Now observe what happens if you store your animation strip horizontally:


    These pixels are stored in memory in the order 12345678ABCDEFGH. To draw the first frame requires pixels 1, 2, A and B. The second frame takes 3, 4, C, and D. And so on. Observe that the pixels required for each frame are not contiguous in memory. This means that they occupy different cache lines at least, and for a bitmap of any significant size, they also span multiple memory pages.

    Now consider a vertically-arranged animation strip:


    Again, the pixels are stored in memory in the order 12345678ABCDEFGH, [typo fixed, 15 Aug] but this time, the pixels of the first frame are 1, 2, 3 and 4; the second frame consists of 5, 6, 7, and 8; and so on. This time, all the pixels for a single frame are adjacent in memory. This means that they can be packed into a small number of cache lines, and reading the pixels for a single image will not force you to jump across multiple pages.

    Let's illustrate with some pictures: Let's say that the large animation is a series of twelve 38x38 frames, for a total bitmap dimension of 38x456. Let's assume further, for the sake of example, that it's a 32bpp bitmap and that the page size is 4KB.

    If the bitmap were stored as a horizontal strip (456x38), then the memory layout would look like this, where I've color-coded each memory page.

    Observe that no matter which frame you draw, you will have to touch every single page since each frame containes a few bytes from each page.

    Storing the bitmap vertically, on the other hand, arranges the pixels like so:

    Notice that with the vertical strip, each frame touches only two or three pages; compare the horizontal strip, where each frame touches seventeen pages. This is quite a savings especially when you realize that most of the time, the only frame being drawn is the first one. The other frames are used only during animation. In other words, this simple change trimmed 60KB out of the normal working set.

Page 1 of 5 (42 items) 12345