Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!sundc!pitstop!sun!oliveb!felix!zemon From: stephent@tekchips.TEK.COM (Steve Tyler) Newsgroups: comp.unix.ultrix Subject: Why Ultrix C library is slow Message-ID: <9433@felix.UUCP> Date: Tue, 13-Oct-87 19:38:41 EDT Article-I.D.: felix.9433 Posted: Tue Oct 13 19:38:41 1987 Date-Received: Fri, 16-Oct-87 04:58:24 EDT Sender: zemon@felix.UUCP Organization: Tektronix Inc., Beaverton, Or. Lines: 21 Approved: zemon@felix.UUCP Reply-Path: Some code compiled with the Ultrix C compiler runs 40% slower than when compiled with the 4.3BSD C compiler. I discovered this by comparing execution profiles of the same code compiled with the two compilers. In the Ultrix version, frexp(), which is a C library routine that separates a floating point number into mantissa and exponent, was the single most time-consuming routine. By disassembling frexp() in the compiled code with adb, I found that the Ultrix version is 27 instructions and the 4.3BSD version is only 5 instructions. For many C library routines there is a C code version and an assembly language version. Clearly DEC is using the slower, larger C code version of frexp(). This version computes the exponent by repetitively dividing its argument by 2 until it is less than 1 (or multiplying, if the argument already is less than one). The number of divides (or multiplies) is the exponent and the resulting double is the mantissa. The assembly language version simply extracts the appropriate bit fields from the argument to get the exponent and mantissa. Of course this is not portable while the C code is, but does Ultrix run on anything besides DEC/VAX hardware anyway?