z (05/11/83)
Both the buffer management and display management routines of CCA EMACS have been completely rewritten from scratch. The result of this effort has been a significant increase in both the efficiency and capability of the editor. CCA EMACS has always had a reputation for being fast, and the algorithms used in the buffer manager were a major reason for this. However, these algorithms had the problem that their efficiency significantly decreased once the size of the file being edited exceeded the internal buffer size. In previous versions of CCA EMACS, the size of the internal buffer was 512K, so this problem was rarely noticed. However, when reading in large files of a megabyte or so, the problem became quite obvious. The new buffer manager does not suffer this problem at all. Using the same 512K internal buffer, the user CPU time required to read in a 1.2 megabyte file was reduced by a factor of six. Even when the size of the buffer was reduced down to 8K, the new routines were still a factor of five faster than the old ones. For files less than the size of the internal buffer, the speed of the old and new routines is comparable. One additional advantage of the new buffer routines over the old ones is that the old limit of 1024 characters per line has been raised to 64K characters per line. Since even binary files tend to have at least one byte which looks like an ASCII linefeed every few thousand characters or so, this effectively means that CCA EMACS can now be used to edit files in arbitrary formats. This is very useful for editing EMACS keystroke files; you can also use it for such things as editing the wizard's password in the rogue object file. The display manager was also rewritten from scratch, and I believe that the algorithms that it uses are close to the optimum possible using a termcap-based display. The new display manager uses all of the relevant termcap fields, so that even really strange terminals should now work correctly with CCA EMACS as long as their termcap description is correct. Other terminals which used to work with EMACS are now supported better than before; for example, scrolling regions are now fully supported for VT100's. The cursor motion routines are much more intelligent than before, and even use somewhat obscure features such as absolute horizontal positioning, absolute vertical positioning, and backtabs, when appropriate. However, the calculations required for these optimizations are small, and their cost is miniscule in comparison to the gain that results from them. The result is that measurements have shown these routines to be more efficient than the cursor motion routines of the vi which came with 4.1BSD, which is the most recent version I have. (I have an old version of Gosling's EMACS, and although my tests show a great difference in efficiency between the display routines of CCA EMACS and my copy of Gosling's, this is probably not conclusive since the copy I used is so old. I would be very interested in running benchmarks against his current version, however.) Another improvement in the display manager is that a complete distinction is now made between buffer lines and screen lines. This means that, unlike some other EMACSes, when you type C-V or M-V, you go forwards or backwards exactly one screenful, regardless of whether there are any intervening wrapped lines. This is especially useful for editing files such as /etc/group, which at large sites may consist mostly of lines wrapped many times. Carrying this distinction to its logical conclusion, going forward a screenful may cause the new screen to start in the middle of a wrapped line. This capability was absolutely necessary in order to permit editing of binary files, where single lines may extend for more than a screenful. Giving arguments to C-V and M-V causes the display to shift the appropriate number of screen (not buffer) lines. In general, the new scheme provides the user with a much more flexible window into any part of the file. One minor change that was made along the way was that the variables Screen Height and Screen Width now refer to the size of the total screen, instead of just the display area. All orders for CCA EMACS which have been received up till now are being filled with this new version.