I wrote FAT on an airplane, for heaven’s sake


When you wrote code for 16-bit Windows, one of the things you spent time doing as part of performance tuning was deciding which functions should be grouped together in which segments.

Code in 16-bit Windows executed out of code segments, each of which could be up to 64KB in size. When a code segment was loaded from disk, the entire segment was loaded, and when it was discarded, the entire segment was discarded. This meant that you could affect your application's performance in significant ways by choosing which functions go in which segments.

For example, it was to your advantage to keep functions that are called at the same time in the same segment, so that they would be loaded as a unit (saving I/O time). If you chose poorly and put unrelated functions in the same segment, then calling any function in the segment caused all the functions to be loaded, which was a waste of I/O since you loaded a bunch of functions you didn't need.

Even if the functions were called at the same time, you also had to keep an eye on their popularity. If you have one function that is called frequently and another that is called infrequently (but always preceded by a call to the first function), the less popular function will ride the coattails of his roommate and remain loaded in memory. This creates unnecessary memory pressure that could cause a function which is moderately-frequently-called to be discarded to make room.

Creating lots of small segments allowed your memory usage to be managed with finer granularity, but it also costs you in general overhead as well as I/O, because each segment load was a new round trip to the disk. You therefore had to balance memory cost against I/O cost.

The process of optimizing the grouping of functions into segments was known as segment tuning.

During the development of Windows 3.0, it was customary to have regular meetings with Bill Gates to brief him on the status of the project. At one of the reviews, the topic was performance, and Bill complained, "You guys are spending all this time with your segment tuning tinkering. I could teach a twelve-year-old to segment-tune. I want to see some real optimization, not this segment tuning nonsense. I wrote FAT on an airplane, for heaven's sake."

(I can't believe I had to write this: This is a dramatization, not a courtroom transcript.)

This "I wrote FAT on an airplane" line was apparently one Bill used when he wanted to complain that what other people was doing wasn't Real Programming. But this time, the development manager decided she'd had enough.

"Fine, Bill. We'll set you up with a machine fully enlisted in the Windows source code, and you can help us out with some of your programming magic, why don't you."

This shut him up.

Comments (47)
  1. Rick says:

    "Fine, Bill. We'll set you up with a machine fully enlisted in the Windows source code, on a plane!"

    [Yup, everybody thought of that after the fact. L'esprit de l'escalier. -Raymond]
  2. Ken in NH says:

    I believe the PC term is "wide body" Mr. Gates. en.wikipedia.org/…/Wide-body_aircraft

  3. John says:

    "I wrote FAT on an airplane"

    Imagine how much better FAT might have been if Bill spent the time to do it right.  :-)

  4. 12BitSlab says:

    Even in the old mainframe days, we used to profile code so we would know how often certain routines were called.  We would then reorder source code to make sure certain routines were relatively close to each other.  

    Back in those days, machines cost millions of dollars and programmers cost thousands.  Therefore, we sacrificed the time of humans to serve the needs of the machine.  Today, we have developers making very good money writing code for a device that retails for $100.  In today's world, we sacrifice the machine to serve the needs of humans.  Today's world is completely upside down from the "olden days".

  5. JM says:

    "I wrote FAT on an airplane" is not an argument that would impress me. It seems to me like it's exactly the kind of thing you would get when writing code on an airplane — which I mean neither negatively nor positively. And I hope that was the day mr. Gates learned that arguments of the form "I did something awesome, why do you continue to suck?" do not tend to inspire people.

  6. alexcohn says:

    @12BitSlab: even today when CPU and RAM are cheap, a program can be installed on millions of gadgets, and optimizing $1 per device is worth the trouble.

  7. 12BitSlab says:

    I don't mind if billg gets a little arrogant at times.  One merely has to look at how he wrote the ROM code for the Altair to realize his abilities.

    Also, ALL of the concepts embodied in modern tablets and smartphones were "invented" by billg when he wrote the code for the Tandy 100.  Things like "instant on", data stored in  non-volitile memory, small productivity apps, continue from the same point after power down, etc.  Persoannly, I put billg in the Top 5 of all-time CS people who contributed to computing.

    BTW, my Top #1 is Alan Turing.

  8. 12BitSlab says:

    @ Alex — I don't disagree with you at all.  However, the cost of that extra $1 per device is distributed of thse users of the software.  In the "Olden Days", we used to write software for a single machine.  Today's development costs are spread over millions or possibly billions of users.  That changes the Math in significant ways.

  9. dave says:

    >continue from the same point after power down, etc.

    Never written a PDP11 powerfail handler, I see.

    (Admittedly that was about carrying on after a complete and unanticipated loss of power, during which you had maybe 10mS to save machine state to core)

  10. Chris says:

    I remember running a benchmark back in the early days of VMS that caused the swapper to swap itself out. Mind you, that was a long time ago. We ran the benchmark in the Dublin office and our save tape was stuck in Irish customs – fortunately someone from Digital realised they could send the code over their internal network – so we actually had something to run, I'm not sure we ever got that tape back!

  11. j b says:

    A related issue: I read a story from long ago, in the early days of IBM 360. The machine did provide paging hardware, but the OS didn't support it (yet). With limited memroy, programmers had to manually manage the overlay of different logical segment in the same physical memory space, always ensuring that no two function that were active at the same time claimed the same physical addresses. IBM released a new version of their system software, including an intellegent linker that tracked all calls and created all the overlay segments automtatically, releaving the programmer of a lot of work. But then, this was also the software release that introduced support for the paging hardware, creating an "unlimited" (virtual) memory space so there was no longer any need for making overlays at alll, it could all be handled in hardware by the paging mechanism.

  12. 12BitSlab says:

    @ j b — the first itreration of S/360 software was released before disk drives were considered ready for the commercial world.  At that time, everything was focused on "unit record processing (i.e. cards).  One didn't need to worry about virtual memory since most of the early programs were ports of code written to run under OS/MFP or OS/MVP.  

    Even though virtual memory wasn't implemented in 1.0 of OS/360, there were hooks ready to support it.  Fred Brooks insisted that virtual memory was the future and that S/360 had to support it no matter what.  That meant that we could write code for unlimited memory and rest assured that our code would be just fine in future iterations.

  13. Mark says:

    Looks like he deserved it. But I suspect it was a career-building move for the program manager…

  14. John says:

    Enough is enough!  I have had it with this motherf*cking code on this motherf*cking plane!  Everybody strap in!  I'm about to open some f*cking windows!

  15. Fleet Command says:

    I may have had been impressed if he had written NTFS v5 on an airplane. And I am not talking about a grounded plane…

  16. Dominic says:

    But did he write FAT on a plane … OVER THE WEEKEND?

  17. DavoFromOz says:

    Speaking of FAT, apparently the morning after Bill Gates' wedding, his new wife was overheard speaking to a friend on the phone: "… and I now know why he called his company Micro Soft…"

    :-P

  18. I was able to write FAT in a cave! With a box of scraps!

  19. jbo says:

    And with edlin as editor

  20. Bob Vila says:

    Looks like Bill did something right as he's giving billions away and everybody else is still a slave….

  21. Mark Ransom says:

    @jbo don't be silly, there was no such thing as a laptop back then. He obviously wrote it on paper while on the plane.

    Probably in pen.

  22. theCoderMan says:

    I say the same thing all the time when the product owner or other non-tech people try to tell me how easy something will be to code.

  23. Joker says:

    The mystery project manager was named Melinda? :-P

  24. Bokmann says:

    This has to be a myth. FAT predates laptops or any other computer that would reasonably be usable on an airplane.

    [You kids say the cutest things. -Raymond]
  25. Rick McKnight says:

    And yet, I feel Bill Gates had a totally valid point, and anybody who has worked with post-Gates era Microsoft software surely knows what I'm talking about.

    I have a much better opinion of him after reading this, to be honest.

  26. mjc says:

    Code on a Plane!!!!  The next big hit, now allowed by the FAA.

  27. Menachen Begin says:

    Noobies, each and every one of you. I built a NAND gate in 1924 using twigs and moss. For delay lines I used a box canyon, and moved about until the acoustic echo distribution in the time domain performed the required function. By May 1925 I had calculated Pi to almost one digit accuracy: 4.

  28. R0ExCC says:

    >>>>>>>>Menachen Begin 10 Oct 2013 5:26 PM #

    >>>>>>>>Noobies, each and every one of you. I built a NAND gate in 1924 using twigs and moss. For delay lines I used a box canyon,

    >>>>>>>>and moved about until the acoustic echo distribution in the time domain performed the required function. By May 1925 I had

    >>>>>>>>calculated Pi to almost one digit accuracy: 4.

    Lemme help you out with your project… I've got backyard full of moss and twigs….

  29. Mike Synnott says:

    @Bokmann : Much of the code we wrote in the 70s and 80s was literally written in a notepad with a pen when we had free moments then coded up and debugged afterwards. He didn't means he literally tapped it into a computer.

  30. Native German says:

    Oh my dear … I've been completely wrong, when reading this article I thought he did a graffiti "FAT" onto an airplane and wondered where the joke is. But reading through the comments I recognized that prepositions are not my best friends.

  31. Chris Sherlock says:

    So he got out a notepad and pen, then wrote the word FAT whilst on a plane. Awesome!

  32. robbohn says:

    @128BitSlab – RE: I don't mind if billg gets a little arrogant at times.  One merely has to look at how he wrote the ROM code for the Altair to realize his abilities.

    The Altair had no ROM – it had front panel switches.  I had a Poly 88 – the first micro that came with a ROM – yay, no more switch flipping to boot the beast.

  33. Winston says:

    He wrote DOS on a single sheet of Holiday Inn note paper on his way to meet with IBM, so writing FAT on a plane should have been a piece of cake.  I never got FAT on a plane – portion size too small.

  34. Russell says:

    Winston – you think he wrote DOS? Check your history. But maybe you were joking.

    Bob Vila – everyone else is not a slave and Bill DID do some things right, as you said, but a lot of it is attributable to being in the right place at the right time doing something for a company that was afraid of looking like they were trying to set up another monopoly, which they had already been sued for by the government in regards to mainframes, and so they were willing to let it be licensed to other PC makers. Bill is obviously a smart guy, but to a certain extent after he got the contract with IBM, it was like a snowball rolling downhill.

  35. N. Haughton says:

    "I built a NAND gate in 1924 using twigs and moss. For delay lines I used a box canyon,"

    If you ever get the chance to visit the Science Museum in London and view the early Pegasus computer that is on display there, you will realise how close to the truth this really is. Coils of spring steel as delay lines to store bits in memory, anyone?

  36. N. Haughton says:

    Gates didn't write DOS, he bought it – it was QDOS, written by another company in Seattle I think. It was adapted to work for the embryo IBM PC.

  37. Warren says:

    Originally called SCP-DOS (Seattle Computer Products)

  38. A. Campbell says:

    The article reminds me a lot of the efficiency issues associated with IBM's CICS, and dates from roughly the same era.  Nowadays there are many ways around performance issues, and the bottleneck is understanding existing code well enough to be able to make a change to it, without introducing defects to existing functionality.

  39. j b says:

    Dave (about three days up the comment chain)> (Admittedly that was about carrying on after a complete and unanticipated loss of power, during which you had maybe 10mS to save machine state to core)

    What would you have to save if you were working on a machine with core memory? Registers? Anything else?

  40. Kaveh says:

    Gate didn't write any FAT. FAT was included with the QDOS that Gate bought for a few thousand dollars and made billions from it.

  41. Br.Bill says:

    Gates didn't originally develop FAT for DOS (or QDOS). It was for Microsoft Stand-alone Disk BASIC-80 for the 8080 processor. It was tweaked for use with QDOS and directory/subdirectory capability was added soon after.

  42. Tei says:

    If you have something that sould take at much 400ms to run, and it need 24 seconds. Tryiing to do optimizations that will gain you nice 25% or maybe even heroic 75% faster computing is completelly useless. You need to make your code some orders of magnitude faster.

  43. Laurence says:

    Thank you, Native German, for the first comment on topic.

  44. This seems particularly amusing with hindsight; I recall IBM boasting – a few years after this point, I think – of the improvements in the next release of OS/2, in particular arranging their code so related functions were on the same page together for much the same reasons. Of course, I also remember segment tweaking two decades later for code on the Palm, which still had 64k segments (and a limitation of 32k jump instructions, IIRC), making porting big chunks of C 'interesting'.

    Now even a cellphone has a 32 bit CPU and hundreds of megabytes of RAM, have we finally seen the last of this, or will we find ourselves in 2030 juggling the code to fit better in the limited resources of injectable nanites?

  45. Orion Blastar says:

    Paul Allen and Tim Patterson did most of the coding that Bill Gates takes credit for.

  46. George Grimes says:

    An alternative view of the origin of the FAT file system from Wikipedia:

    Marc B. McDonald is an American who was Microsoft's first salaried employee (not counting Monte Davidoff, who wrote the math package for BASIC for a flat fee). He is credited with designing the FAT File System for Standalone Basic which was the file system for the MS-DOS operating system and Microsoft Windows.

  47. 640k says:

    How did bill store the source code?

    [He put it in his pocket, probably. -Raymond]

Comments are closed.