Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 15 Jan 1999 20:16:13 -0500
From:      "Louis A. Mamakos" <louie@TransSys.COM>
To:        Terry Lambert <tlambert@primenet.com>
Cc:        freebsd-hackers@FreeBSD.ORG
Subject:   Re: TSS and context switch 
Message-ID:  <199901160116.UAA58724@whizzo.transsys.com>
In-Reply-To: Your message of "Fri, 15 Jan 1999 23:36:10 GMT." <199901152336.QAA20785@usr04.primenet.com> 
References:  <199901152336.QAA20785@usr04.primenet.com> 

next in thread | previous in thread | raw e-mail | index | archive | help

> One of the people I went to school with, Val Kartchner, did an
> "infinite" precision math library using VAX assembly.  He could
> tell you very accurately which instructions were emulated on which
> VAXen.  All I can rememebr is the CRC32 instruction on the uVAX...

The other one I tripped over due to incorrect emulation on a MicroVAX-II
was the matchc instruction.  This was, of course, used in MH in some
scary looking code to parse RFC-822 headers that was hacked by Van
Jacobson.  The module in question (still in NMH) is sbr/m_getfld.c.  The
long comment at the start of the file begins:

/* This module has a long and checkered history.

and then:

  (Written by Van Jacobson for the mh6 m_getfld, January, 1986):

   This routine was accounting for 60% of the cpu time used by most mh
   programs.  I spent a bit of time tuning and it now accounts for <10%
   of the time used.  Like any heavily tuned routine, it's a bit
   complex and you want to be sure you understand everything that it's
   doing before you start hacking on it.  Let me try to emphasize
   that:  every line in this atrocity depends on every other line,
   sometimes in subtle ways.  You should understand it all, in detail,
   before trying to change any part.  If you do change it, test the
   result thoroughly (I use a hand-constructed test file that exercises
   all the ways a header name, header body, header continuation,
   header-body separator, body line and body eom can align themselves
   with respect to a buffer boundary).  "Minor" bugs in this routine
   result in garbaged or lost mail.

   If you hack on this and slow it down, I, my children and my
   children's children will curse you.

and later:

                 * packed maildrop - only take up to the (possible)
                 * start of the next message.  This "matchc" should
                 * probably be a Boyer-Moore matcher for non-vaxen,
                 * particularly since we have the alignment table
                 * all built for the end-of-buffer test (next).
                 * But our vax timings indicate that the "matchc"
                 * instruction is 50% faster than a carefully coded
                 * B.M. matcher for most strings.  (So much for elegant
                 * algorithms vs. brute force.)  Since I (currently)
                 * run MH on a vax, we use the matchc instruction. --vj

Of course, this code had an "#ifdef vax" optimization using an asm()
of a scanc instruction.  So the attempt at optimizing was pessimized by
trapping into the (broken) kernel emulator for the complex instruction.
I suppose when you had 50 people sharing a 1 or 2 MIPS CPU, you resorted
to this stuff.  I know I was guilty of it on an old Univac 1108 with
262K of (36-bit words) memory that ran 40 or 60 people.

This truly was a pain in the ass to find; typically, you expect the
instructions to work.

louie



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199901160116.UAA58724>