Path: utzoo!attcan!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!sdd.hp.com!hplabs!hpda!hpcuha!aspen!hpcc01!hpbbn!hpbbrd!hpfcmdd!hpfcso!hpldola!hp-lsd!was From: was@hp-lsd.COS.HP.COM (Bill Stubblebine) Newsgroups: comp.os.cpm Subject: How to speed up Ampro LB+ SCSI? Message-ID: <8190004@hp-lsd.COS.HP.COM> Date: 31 Jul 90 16:02:55 GMT Organization: HP Logic Systems Division - ColoSpgs, CO Lines: 127 I have a question for any Ampro Little Board Z80+ BIOS hackers still left out there. My configuration: Ampro LB Z80+ (w/built-in SCSI interface) Adaptec ACB4000 (not 4000A) SCSI hard disk controller Seagate ST-125 20 MB 40 ms hard disk drive 3M MCD-403 40 MB QIC SCSI tape drive NZ-COM/Z-System I've used this system for several years. Until recently, I've never had reason to complain about the speed of the LB+ BIOS SCSI routines talking to my hard disk because most programs and editor text load within human tolerance limits, i.e., < ~1-3 seconds. Recently, I purchased the 3M MCD-403 SCSI tape drive to support backups. It was a good deal for $129 surplus at Halted Electronics in Sunnyvale. The tape drive works great, and the Ampro BIOS provides a convenient virtual machine for accessing the SCSI bus. Within a very short time I was able to exercise the tape drive's basic features via SCSI. As I started transferring real data between the hard disk and the tape drive, I discovered that I could not source or sink data from the hard disk fast enough to keep the tape drive streaming. (Streaming means keeping the tape drive motor continuously running during data transfers.) Without maintaining streaming operation, the tape transport stops, repositions the tape and starts up again to read or write each physical block on the tape. Because this extra positioning activity will probably reduce the life of the tape transport, it looks like I need to speed up the hard disk accesses slightly. A few more details on the tape drive. The tape drive reads and writes 8k byte physical blocks. A single SCSI command can transfer multiple 8k blocks to or from the tape, but never less than one block. To keep the tape drive streaming the host needs to request a read, write or seek operation from the tape drive within 250ms of a prior read, write or seek operation, otherwise the tape drive motor shuts down automatically. A few more details on the disk drive and controller. The Adaptec ACB4000 controller formats the ST-125 using 18 512-byte physical sectors (or logical blocks as the controller manual refers to them) per physical track. Thus, one physical track on the disk contains 72 logical (128-byte) CP/M sectors, with four 128-byte CP/M sectors per each 512-byte SCSI logical block. The Ampro BIOS computes CP/M sector and track numbers based on 64 128-byte sectors per track, and converts the CP/M track/sector numbers into SCSI Logical Block Addresses (LBAs) as part of processing BIOS read, write and seek requests. I mention this so that in the following discussion when I refer to logical sectors, you will know that I am not talking about CP/M sectors and tracks, but logical 512-byte SCSI logical blocks. The SCSI logical blocks are physically positioned in relation to each other on the track based on the interleave factor specified to the Adaptec controller at format time. The Adaptec controller supports interleave factors from 1:1 to 9:1, i.e., the fastest interleave (1:1) is when sequential logical sectors occupy adjacent physical locations on the track, while the slowest interleave (9:1) has eight physical SCSI sectors between each logical SCSI sector. The ST-125 spins at 3600 RPM = 60 RPS => 16.67 ms/ revolution. Thus, the drive has a basic latency of 16.67/2=8.33 ms, i.e., the average time you need to wait before the desired physical block arrives under the head, assuming, of course that the head is positioned over the desired track. I've spent some time characterizing the hard disk operation. To my surprise, even with the ST-125 formatted at the slowest interleave (9:1), the BIOS cannot transfer the contents of a 512-byte SCSI logical sector in time to read the next SCSI logical sector on the same track nine sectors away. In fact, careful measurement revealed that after reading a SCSI sector, at 9:1 interleave the the BIOS **just misses** the next available logical sector, and has to wait for the next revolution. For example, after reading physical sector 1, the nearest physical sector that the BIOS can read on the same track during the same rotation is physical sector 11 as illustrated below: One track: <--------------------- 16.67 ms --------------------> Physical: 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 Logical: 01 03 05 07 09 11 13 15 17 02 04 06 08 10 12 14 16 18 One sector: <---------- 8.33 ms -------> I did these experiments using bona fide BIOS calls just as an application program would. I transferred each 512-byte SCSI block to memory using four sequential CP/M sector requests starting with the CP/M sector that mapped onto the first of the four CP/M sectors in the SCSI physical block. (Believe me, that was an interesting exercise in integer programming.) I timed the SCSI block transfer starting from just before the first CP/M sector request till just after the fourth sequential CP/M request. These were BIOS sector reads and writes - no BDOS overhead was involved. I realize that reading 4 CP/M sectors per SCSI sector involves overhead in the BIOS deblocking code. I estimated the overhead of the deblocking code by measuring the time to transfer a 128 byte CP/M sector I knew was already buffered in the BIOS deblocker. This took a little less than 1 ms per CP/M sector - not fast, but also nowhere near the 8ms+ required for the entire 512 SCSI block. The results indicate that the BIOS is taking > ~4ms to read a measly 512 bytes per physical SCSI sector. Overall, the net throughput of the Ampro SCSI HD interface seems lower than it should be. The best it can do is four 128 byte CP/M sectors per 16.6 ms disk revolution, or 512 bytes/16.6ms. Thus, even with a 1:1 interleave so that logical sector 2 is right next to logical sector 1, transferring 8k bytes requires: (8192/512 sectors)*16.67 ms/sector = 16*16.67 = 266.72 ms This equates to only 30,713 bytes per second net throughput from the hard disk - not too impressive in my opinion. Add to this any randomness in a file's disk allocation involving head seek time, and I'm out of the ball park for streaming. If I could speed up the processing of a SCSI logical sector by one or two milliseconds, I could double the throughput at an interleave of 9:1, because the BIOS could transfer two SCSI logical sectors per revolution instead of 1 SCSI sector per revolution as it does now. If you're still with me, I wonder if anyone has managed to get more than 30.7K bytes per second net throughput to/from the hard disk out of a configuration similar to mine. I've read the Ampro BIOS source and the Adaptec technical manual several times without finding a clue to speeding things up further. What's the trick? Bill Stubblebine Hewlett-Packard Logic Systems Div. was@hp-lsd.hp.com (Internet) (719) 590-5568