Facc: A Floppy Accelerator By ASDG - Copyright 1987 By ASDG Incorporated This manual is provided in machine readable form for your convenience. We've trusted you. Please reaffirm that trust by not copying this manual (or Facc) to other persons. Thanks - We Do Appreciate It. Perry S. Kivolowitz President, ASDG Incorporated Compuserve: 73170,2663 Bix: perry or asdg (201) 540 - 9670 1. Overview Of Facc Facc is a program which boosts the apparent performance of floppy disk operations by providing a dynamically managed cache in Fast or Chip memory. 1.1 Defining Chip Memory, Fast Memory, and Cache Chip memory is the first 512 kilobytes of memory on the Amiga personal computer. Chip memory is so named because it is the only memory addressable by the custom chips inside the Amiga which control graphics, sound, and floppy disk operations. Fast memory, often called expansion memory, is optionally provided in addition to the 512 kilobytes of Chip memory. The Amiga can address more than sixteen times as much Fast memory as Chip memory. While Fast memory can hold programs and some data, information which is to be manipulated by the Amiga's custom chips cannot reside in Fast memory. A cache is a collection of data taken from a large but slow device (like a floppy disk drive) and placed in a small but fast device (like memory). Before an access is made to the slow device, the fast device is checked to see if the sought after information is already in the fast device. If so, the request is serviced from the fast device without ever having to access the slow device. If the sought after information is not in the fast device then the request is actually sent to the slow device. Once the requested has been serviced by the slow device, a copy of the sought after data is placed in the fast device so that should the same data be requested again, it will be found in the faster device. Ideally, a cache will have a very high ``hit ratio.'' A hit ratio is a measure of how often data is found to be already in the fast device (the cache). If a total of 100 read requests were made of which 90 were found to already be in the cache, the hit ratio of this cache would be 90 percent (or 90 out of 100). However, the cache begins in an empty state so all initial requests revert to the slow device. As the cache begins to fill and previously requested data is requested again, the hit ratio will begin to climb. Dramatic performance improvements can be had when specific requests are made again and again. 1.2 Facc Versus AddBuffers A program which comes the version 1.2 of the Amiga operating system also provides a floppy disk caching facility. This program, called AddBuffers, differs from Facc in many important ways. First, AddBuffers declares its cache buffers only in Chip ram. So to achieve better disk performance by allocating many cache buffers through AddBuffers will sacrifice vital Chip memory. Facc, on the other hand will use Fast memory if available and if not will revert to Chip memory. If you have Fast memory and had been using a large number of buffers supplied by AddBuffers then by using Facc (and eliminating the AddBuffers supplied buffer by not invoking AddBuffers) you can gain a significant amount of available Chip memory. Second, once buffers are allocated by AddBuffers they can never be deallocated. This is compounded by the fact that there is no way to tell how many buffers are currently allocated by AddBuffers. Facc allows the complete and total dynamic management of the number of buffers used by the floppy disk cache. At any time you may add buffers to the cache (increasing its effectiveness) or remove buffers from the cache (freeing more memory to be used by other programs). Third. Facc presents a dynamically updated graphic display of exactly how many buffers are in the cache and to what purpose there are assigned. You can use this information to monitor disk activity, fine tune buffer allocations, or simply keep yourself entertained by the changing numbers. 2. Installing Facc (In the following paragraphs, WorkBench disk refers to your working copy of the WorkBench, not your original which should be in a safe place!) Facc is intended to be started from the WorkBench. To install Facc Double click on your WorkBench disk icon. This should bring up a window containing several drawers including one marked ``System.'' If that drawer is not present, look for one marked ``Utilities.'' If neither is present then you are not working with a standard WorkBench disk so rather than install Facc in the usual places install it where you wish (read the following paragraph and improvise!). Double click on the Facc distribution disk icon. This should bring up a window containing a drawer marked (again) ``System.'' If the drawer does not appear in the Facc distribution disk window then your are not working with a standard Facc distribution disk. Try hunting for the Facc program on the Facc distribution disk using the CLI. If you are unsuccesful then report this problem to the provider of your distribution disk. Double click on the ``system'' drawer found on the Facc distribution disk. This should bring up a number of icons of which one will be marked ``Facc.'' If you don't see it follow the advice given in the previous paragraph. Now, move the mouse to directly over the Facc program icon. Depress the left mouse button and hold it. While holding the left mouse button drag the Facc program icon to directly over the ``System'' drawer on your WorkBench disk. Confirm that the Facc program has moved onto your WorkBench disk by double clicking the ``system'' drawer on your workbench disk. When the window completes its rendering, you should see the Facc program icon somewhere in the window. Facc can be run from the CLI in the usual way but please note that Facc does not detatch from the invoking CLI. Therefore, should you do an ENDCLI from the invoking CLI, the CLI window will remain until Facc exits. At this time, we know of no ``perfect'' way to fully, completely, and reliably detatch a process from the CLI without side effects such as loss of memory etc. However, we have provided you with the freely redistributable program ``RunBack'' by Rob Peck late of Commodore-Amiga. Using RunBack, Facc can be started from the CLI yet the CLI will be allowed to exit by a subsequent CLI. The only negative side effect of RunBack will be the loss of 48 bytes per each use of RunBack. RunBack is located in the ``c'' directory on the Facc distribution disk. 3. Starting Facc To start up Facc simply double click on its icon. Facc will automatically detect if another copy of Facc is already running and if so, will exit quietly. Thus, no harm can be done by attempting to run Facc many times while it is already running. Facc can be started from the CLI by ``run''ing it in the usual way. However, Facc will not detatch itself from the current CLI which means that the CLI window from which you started Facc will not go away until Facc goes away. However, as described above, we have provided you with a program called RunBack which will start Facc from the CLI yet still allow the starting CLI to exit on an ENDCLI. However, RunBack loses 48 bytes each time it is invoked. A short time after you have double clicked on the Facc program icon or after you have run Facc from the CLI, the Facc window will appear in the upper left hand corner of your WorkBench (or CLI) screen. If no window appears check to see if Facc is already running by looking for its window underneath other windows. Everything Facc needs to run is found in the Amiga ROM Kernel so there is no reason why Facc should ever fail to run except if there was not enough Chip memory to even open its window. 4. Stopping Facc Facc can be caused to exit (returning all buffers to the Amiga free memory pool and disabling the caching effect) by simply clicking on the Facc window's Close Gadget. This can be done at any time even when floppy operations are currently in progress. If Facc is exited, the next time it is run it will have to build up another cache. 5. Understanding The Facc Window The Facc window is divided into selectable and non-selectable regions. Non-selectable regions are surrounded by a heavy border while selectable regions are identified by their lighter boarder. Non-Selectable regions are used to convey status information and to label the Facc window. For example, the large heavy bordered region dominating the center of the Facc window indicates the exact status of the buffer cache with respect to as many as four floppy disk drives. There are three selectable regions in the Facc window. Let's call these buttons. See if you can identify the three buttons at this time. If you identified the three buttons as being in the upper left corner, the lower left corner, and the lower right corner then you've identified the three buttons correctly. The button in the upper left corner serves a dual purpose. It provides a dynamically updated measure of the total amount of free memory in the system. This measure includes both Chip and Fast (if you have some) ram. Its second function will be described shortly. 5.1The More And Fewer Buttons The other two buttons, marked ``Fewer'' and ``More,'' are used to dynamically control the number of buffers in the buffer cache. The button marked ``Fewer'' will decrease the number of buffers in the buffer cache (and increase the amount of free memory available for other tasks). The button marked ``More'' will increase the number of buffers in the buffer cache (increases the cache's effectiveness but decreasing the amount of free memory available for other tasks). Both of these buttons can be depressed and held causing their effect to be applied continuously. If while holding down either button you move the mouse outside the boundary of the button the effect of the button will stop. Right now, try quickly clicking on the ``More'' button and watch the total amount of free memory. Did you notice it decrease? Try quickly clicking on the ``Fewer'' button. Did the amount of free memory increase? As you click on either the ``More'' or ``Fewer'' buttons also notice that the total number of buffers shown in the bottom line of the ``Total'' region is also changed to reflect either more or fewer buffers available for Facc to use. Now try depressing the ``More'' button and holding it. Notice that the effect of the ``More'' continues to occur while the left mount button is depressed over the ``More'' button. When you get into memory tight situations or simply wish to reduce the number of buffers, depress and hold the ``Fewer'' button. When you wish to increase the number of buffers to increase the effectiveness of the cache simply depress and hold the ``More'' button. A word of caution: try to leave a substantial amount of free memory left available when adding buffers to Facc. You can monitor the amount of free memory left by watching the contents of the button in the upper left corner of the Facc window. 5.2 The Shrink-Window/Free-Memory Button As mentioned before, the button in the upper left corner of the Facc window serves a dual function. First, it constantly displays the amount of memory still available to the system. And second, it is the Shrink-Window button. The Facc window is a large one. You may wish to have it occupy less on-screen space from time to time. Simply click within the borders of this button and the Facc window will shrink to a very small size. The contents of the window is replaced with the word ``Expand.'' Click anywhere inside the window to cause Facc to grow to its former shape and size. Don't worry about where to place the small Facc window. When the ``Expand'' button is selected, Facc will automatically adjust the position of the expanded window so that it will fit properly on your WorkBench or CLI screen. Try clicking in the Shrink-Window button now. Did the window shrink? Drag the shrunken window over to the bottom right hand corner of your screen. Depress the ``Expand'' button now. Notice that Facc moved to the left and up before the window actually expanded. 6. AddBuffers And Facc If you had been using AddBuffers before purchasing Facc, stop. Take the calls to AddBuffers out of your startup-sequence if that is where they were. AddBuffers will simply get in the way when Facc is around and will tie up valuable Chip memory. 7. Using Facc With the Facc window fully expanded, double click on your WorkBench disk's icon (if the window was alread open then close it, if you are working from the CLI read the tutorial information here and perform ``DIR''s where the following chapter says to open a disk window.). Notice that the window filled at normal speed. Notice also that numbers started flashing into one of the columns in the ``Drive'' region as well as in the ``Total'' region. Facc cannot determine which floppy drive is DF0: and which is DF1:. However, Facc can tell the units apart so no data bound for one unit will ever be sent to the wrong unit. Each column of the ``Drive'' region corresponds to the buffer activity going one for each drive. The first drive referenced after Facc begins executing will be drive A then second will be drive B and so on. The ``Reads'' row tells you exactly how many times the floppy disk device driver has been asked to read a block from any of your floppies. Each time a read request is serviced (irrespective of if the block was in the cache already or had to be located on the floppy drive) the ``Reads'' row will be incremented in the column representing the particular drive effected and also, the Total Reads will be incremented as well. Similarly, the ``Writes'' row identifies the number of write requests each drive has been given. The ``Read Hits'' row identifies how times a read request occured and the sought after block was already in Facc's cache. The first time you opened the WorkBench disks's icon, the number of reads will increment by some amount probably between 10 and 40. Notice however that the number of ``Read Hits'' will probably increment by 2. This is because this is the first time Facc has seen the blocks requested from the WorkBench disk. Close the WorkBench disk window and reopen it. This time, the number of ``read hits'' should go up the same amount as the number of reads. This is because the sought after blocks are already in the cache. 7.1 The ``Buffers'' Row - Fine Tuning Facc As buffers are assigned to a drive (say Drive B), the corresponding ``Buffers'' column will incrment. If the sum of numbers in the four ``Buffers'' columns is less than the value found in the ``Buffers'' Total column, then free buffers exist and will be used. If the sum is equal to the total, then all of the buffers are currently in use and assigned to your floppy disk drives. If additional buffers are required to service new requests Facc will recycle the current buffers reusing the buffers from the least recently used buffer first to more recently used buffers later. This ``Least Recently Used'' or LRU approach to buffer management has a good point and a bad point. The good point is that blocks which are used more frequently will tend to stay in the buffer. The bad point comes about when a single operation, say doing a ``Dir Df0: Opt A'' will exhaust the number of buffers causing the first buffers allocated to the disk to become recycled for later buffers. This is called thrashing and it is not a good thing because the benefits of the cache are undone by constantly having to refill buffers that had been filled previously but had to be reused. Fortunately you can tell if this situation is present simply by looking at the expanded Facc window. If all of the buffers group into one column (the ``Drives'' region, ``Buffers'' row) and still reads are percolating to the floppy disk, then thrashing is occurring. Simply depress the ``More'' button to increase the number of buffers. Or if the numbers of buffers allocated to one drive decreases so that another drive may receive more buffers and you wish to maintain the cache for BOTH drives, also simply increase the number of buffers. 8.The ``Percentage'' Row The ``Percentage'' row indicates how effective the cache has been for you on a per drive basis. It is the ration of ``Read Hits'' to ``Reads.'' The closer the ``Percentage'' is to 100 (the theoretical maximum) the better. 9. Things You Should Know About Facc 9.1 What Happens When A Write To Floppy Occurs When a write request comes in for a specific block on a drive, the cache is checked to see if the block is alread in the cache. If it is, the information contained in this buffer is discarded since it is no longer current. Then the write is passed on the to normal floppy write routines with no alteration. Once the write has completed, a new buffer (probably the one just deallocated) will be assigned to hold the newly updated block. This way, the performance of editors, word processors, data base systems and other applications which do a lot of writing out then reading in, will be increased. 9.2 What Happens When A Floppy Is Removed From A Drive Facc automatically detects when you remove a diskette from a drive. When this happens all of the buffers which might have been associated with the drive are discarded (made available for other use). This prevents data from being written to the wrong disk or for inconsistent data to be written to the right disk. Try this now. With the disk activity light out, remove a floppy which you have recently accessed. Notice that the number of buffers will go to zero when the diskette is removed. This means that the cache for that drive will have to be built up again. This is more reasonable than risking corrupting a disk. 10. Bonus Programs Included On This Disk 10.1 FastMem FastMem is a program which may help to execute programs which do not work correctly with Fast memory. Clicking on the FastMem icon will remove all Fast memory from the system's free memory list. Clicking on the FastMem icon again will put all of the Fast memory back onto the free memory list. FastMem is used before execution a program which was not written to correctly handle Fast memory (these are usually older programs). Once the errant program begins running (loaded into Chip memory since no Fast memory was available) FastMem can be executed a second time to bring back the Fast Memory. This program was originally distributed along with the ASDG Recoverable Ram Disk and is provided here as a no cost bonus program. 10.2 SysMon SysMon is a program which dynamically monitors system performance. Clicking on the SysMon icon will bring up a window which contains various graphical representation of things going on on your Amiga. From top to bottom and left to right these are: I/O Int/Sec represent the number of I/O interrupts per second due to keyboard and floppy disk activity. Waiting Tasks represents the number of tasks loaded into the Amiga but are not running because they are waiting for some event to occur (like a gadget to be selected). Ready Tasks represents the number of tasks loaded into the Amiga but are not running because some other task IS running. These tasks would be running if some other task wasn't already running. The current running task is not figured into the Waiting Tasks or the Ready Tasks since it is actually running. CPU Utilization represents the percentage of time that the CPU (your Amiga's Motorola 68000) is doing meaningful work. Using the standard workbench colors, the more orange that shows the busier the CPU is. Swch Actvty represents the number of times per second that the Amiga is switching from task to task. This number will always be fairly high. For example, typing into an editor will cause the Amiga to constantly switch between the editor and the input device which handles input. Chip Ram represents the percentage of free Chip ram available. The exact amount of Chip memory available is shown in parenthesis while the graphical representation indicates what fraction of Chip memory is still available by the amount of orange in the graph. The more orange, the more Chip memory is still available. For each and every Fast Ram board you will have a graph similar to the Chip Ram line but labeled Fast Ram 0, Fast Ram 1 and so on for each Fast memory board you have in your system. This program was originally supplied along with the ASDG Recoverable Ram Disk and is provided here as a no cost bonus program. 10.3 DropCloth DropCloth is a program which will cause the surface of your WorkBench to contain one of 64 patterns. This makes a rather pleasing display since the interior of each window will be the normal blue background while the surface of the WorkBench outside of any window will have a white pattern. DropCloth can only be run from the CLI at this time. It takes an integer argument specifying the pattern to be used in the background. There are 64 patterns ranging from 0 to 63. The default is 32 (running DropCloth with no argument produces the default condition). Each pattern is an 8x8 dither mask which produces an even gradiation of blue to white. For example, 0 is solid blue. Thirty two is an even mix of blue and white. And, 63 is solid white. The values of 32, 40, and 42 are pleasing to us, you might like them as well. Sometimes when running DropCloth, some window frames may not be redrawn fully. To fix this simply depress the right mouse button. Try ``run DropCloth 42'' DropCloth does not detatch from the starting CLI so doing and EndCLI will cause the CLI window to stick around until DropCloth is exited. However, as noted else where we have provided RunBack, written by RobPeck late of Commodore-Amiga which will allow DropCloth to be run from the CLI yet still allow the CLI to exit on an ENDCLI. DropCloth is provided for your amusement only. It itself consumes no CPU time. However, a by-product of DropCloth's presence causes added overhead to the layers library (the code which manages windows obscuring other windows). So, while DropCloth may make a nice display it does slow down windowing slightly. Use it at your discretion. DropCloth is located in the C directory of the Facc distribution disk. 10.4 RunBack RunBack is written by Rob Peck of Commodore-Amiga and is freely redistributable. It allows programs to be started from the CLI and still allow the invoking CLI to be exited by a subsequent ENDCLI command. However, RunBack loses 48 bytes each time it is run. This might not be of any consequence but then again it might. Try ``RunBack DropCloth 40'' or ``RunBack Facc'' to start DropCloth with pattern 40 or to start Facc. RunBack is located in the C directory of the Facc distrubution disk.