Dream and Reality: Incremental Specialization in a CommercialOperating System

Conventional operating system code is written to deal with all possible system states, and performs considerable interpretation to determine the current system state before taking action. A consequence of this approach is that kernel calls which perform little actual work take a long time to execute. To address this problem, we use specialized operating system code that reduces interpretation, but still behaves correctly in the fully general case. We show that specialized operating system code can be generated and bound incrementally as the information on which it depends becomes available. We extend our specialization techniques to include the notion of optimistic incremental specialization: a technique for generating specialized kernel code optimistically for system states that are likely, but not certain, to occur. The ideas outlined in this paper allow the conventional kernel design tenet of "optimizing for the common case" to be extended to the domain of adaptive operating systems. We also show that aggressive use of specialization can produce in-kernel implementations of operating system functionality with performance comp[arable to user-level implementations. We demonstrate that these ideas are applicable in real-world operating systems by describing a re-implementation of the HP-UX file system. Our specialized read system call reduces the cost of a single byte read by 50%, and an 8 KB read by 20%, while preserving the semantics of the HP-UX read call. By relaxing the semantics of the HP-UX read we were able to cut the cost of a single byte read system call by more than an order of magnitude.