August 91 - Re: Segments from Outer Space
Re: Segments from Outer Space
Jeff Alger replies to Kent Sandvik's "Children of the DogCow-Segments from outer space", which appeared in the June 1991 issue of FrameWorks.
I'm writing to take issue with two things said regarding segmentation vs. VM in your otherwise excellent article on segmentation in the June Frameworks. Just setting the record straight.
First, you mentioned Unix thrashing is due to page after page being loaded as a thread of function calls is followed. As someone who has worked with Unix systems for almost 15 years now, that is the least likely reason for a thrash-and when it does occur, it is a symptom, not the disease. In almost all Unix thrashing, the problem is simply that you are trying to run too many applications with too big a cumulative space requirement at once. If you were using a Mac, you couldn't even make the attempt, so it is poor sportsmanship to knock Unix for at least trying.
The Mac forces you to partition the memory space, with fixed-size allocations per process, while Unix allows the VM hardware to allocate memory across applications as demand shifts. A classic prescription for this kind of thrashing in Unix is to use shared libraries, something that segmentation actually discourages (jump tables are application-specific, as are the memory spaces used to load the segments). In short, Unix does thrash, but only after it has far surpassed the Mac scheme's ability to juggle the same load.
The second thing that I wanted to comment on is your claim that segmentation solves tight memory problems better than VM. If someone at Apple has been able to prove this with real numbers or some sort of statistical model-quick! nominate them for a Turing Award. Maybe he or she can next develop a generalized sorting algorithm with better than n*log(n) performance. If asked, I'll certainly back the nomination.
Humor aside, the only reasons that segmentation is a better strategy than VM for the Mac are backward software compatibility, compatibility with non-VM Macs, and the fact that a reliable VM kernel is more difficult to implement than simply forcing applications to do their own housekeeping.
Performance of a segmented system must be worse than a VM system for so many reasons, I don't know where to begin: segmentation results in less efficient allocation of memory across the whole machine, since process sizes are fixed, while VM automatically balances memory usage among competing processes; segmentation results in larger swaps than the standard 4K page size of VM; VM allows seldom-used data to be swapped, while segmentation deals only with code; segmentation is a software-only solution, while VM is implemented in low-level hardware (in on-chip hardware for 68030's and 040's); segmentation is not suited to interrupt-time swapping, or for that matter, interrupt-driven multitasking, since it only applies at the start of a function call, while VM allows swap-outs to happen any time without damage; segmentation leads to the need for larger reserves of space-worse, larger reserves for each process-since memory is used less efficiently and an entire segment must be loaded in order to recover from a fault; less efficient use of space also results in more swapping, fewer processes, or both; segmentation works against sharing code across applications and creating truly integrated object-oriented operating systems and applications, since it forces an application, rather than system, perspective on memory usage… I'm out of breath.
Kent, I'm not unloading on you personally, but I am getting tired of the lack of justification from Apple for segmentation vs. VM. At first, I sat back and waited for a good explanation, but none has come out in the couple of months this issue has been thrashed out (if you'll excuse the pun) on MacApp.Tech$. Just recycled potshots. Does anyone have any real numbers, or is this just a "let's trash Unix because we didn't invent it"-party?
Your article was great otherwise, and I learned a lot from it. Keep up the good work, in FrameWorks and in your responses to MacApp.Tech$. You're doing a good job of filling Keith's shoes.