The Unix Heritage Society mailing list
 help / color / mirror / Atom feed
From: John Gilmore <gnu@toad.com>
To: Dan Cross <crossd@gmail.com>
Cc: TUHS main list <tuhs@minnie.tuhs.org>
Subject: Re: [TUHS] tangential unix question: whatever happened to NeWS?
Date: Mon, 25 Jan 2021 15:46:34 -0800	[thread overview]
Message-ID: <9727.1611618394@hop.toad.com> (raw)
In-Reply-To: <CAEoi9W4TMh=SSrk=pqprark7+ctvZLsbW8h00pf31KbtUAy_CQ@mail.gmail.com>

Dan Cross <crossd@gmail.com> wrote:
> I guess it's potentially faster if you don't have to swab
> bytes between similar architectures?

The "potential" speedup is completely superficial, and the N^2
complexities make the code hard to test and hard to maintain.  It's
better to do something simple and correct, and then you can leave it
untouched for a decade.

I implemented the byte-order handling code in the GNU BFD library back
in the early '90s.  We picked up every integer as a series of unsigned
byte accesses and shifted them and added them, even when the byte order
of the data matched the byte order of the machine.  Some machines can do
unaligned 4- or 8-byte fetches and some can't.  The people who design
object file formats (or packet formats) don't always align things on the
boundaries that your hardware prefers.  We wrote simple, easy to test
code that would and did run on ANY machine.  We did the same for stores
as well as loads.

Every data structure had two representations: The external one, defined
by a struct full of unsigned char arrays; and the internal one, in
native data formats.  For each data format, we wrote a trivial routine
to convert the external format to the internal; and its inverse.  These
called a series of the lower level pick-up-bytes-in-particular-order
routines, one call per struct member.  None of this was even inlined at
the time.

I never measured the overhead of these get- or put- routines as being
above 1% or 2% in the execution of the whole program (e.g. the GNU
linker).

We had enough complexity to deal with already, because every vendor made
their own slightly different version of COFF or ELF or a.out object file
formats.  Some of these were in different byte orders.  Some truly
insane vendors had the object file HEADERS in one byte order and the
actual binaries in a different byte order!  We made a library that could
read and write them all -- and manage their symbol tables -- and even
link them together from a variety of formats and write the resulting
binary in a different format.  This was all part of making the GNU
compilers into cross-compilers, in which your "host" byte order and
object file format are completely orthogonal to your "target" byte order
and object file format.  We then built test suites that built the same
test code on a dozen host systems and made sure that all the resulting
binaries for target system "X" were bit-for-bit identical.  Building in
those capabilities, and that level of reliability, was much more
important than any 2% speedup.

Premature optimization is the root of much evil.

	John
	

  parent reply	other threads:[~2021-01-25 23:56 UTC|newest]

Thread overview: 71+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-24 16:14 ron minnich
2021-01-24 16:24 ` Michael Kjörling
2021-01-24 17:04 ` Clem Cole
2021-01-24 18:36   ` Larry McVoy
2021-01-24 20:39     ` Ronald Natalie
2021-01-24 20:54       ` Larry McVoy
2021-01-24 21:01         ` Ronald Natalie
2021-01-24 23:38         ` Grant Taylor via TUHS
2021-01-25  0:18           ` Larry McVoy
2021-01-25  0:36             ` Grant Taylor via TUHS
2021-01-25  0:41               ` Larry McVoy
2021-01-24 20:45     ` Jon Steinhart
2021-01-24 21:11       ` Larry McVoy
2021-01-24 21:14         ` Jon Steinhart
2021-01-24 21:22           ` [TUHS] Apollo (was NeWS) Ronald Natalie
2021-01-24 21:25           ` [TUHS] tangential unix question: whatever happened to NeWS? Larry McVoy
2021-01-24 22:53             ` Dan Cross
2021-01-24 23:33               ` Jon Steinhart
2021-01-25  0:11                 ` Al Kossow
2021-01-25  0:21                   ` Jon Steinhart
2021-01-25 14:38                     ` Clem Cole
2021-01-25 15:31                       ` Al Kossow
2021-01-25 15:55                         ` Richard Salz
2021-01-25 16:04                           ` Larry McVoy
2021-01-25 16:37                             ` Dan Cross
2021-01-25 16:49                               ` Richard Salz
2021-01-25 17:11                               ` Bakul Shah
2021-01-25 17:25                               ` Larry McVoy
2021-01-29 20:24                                 ` Dave Horsfall
2021-01-29 20:31                                   ` Larry McVoy
2021-01-25 23:46                               ` John Gilmore [this message]
2021-01-29 19:53                               ` Dave Horsfall
2021-01-25 22:25                           ` Rob Gingell
2021-01-26  1:38                           ` Jon Steinhart
2021-01-27  3:11                             ` Dave Horsfall
2021-01-27  3:54                               ` Jon Steinhart
2021-01-27  5:15                                 ` George Michaelson
2021-01-27  5:52                                   ` George Michaelson
2021-01-27  5:48                                 ` Grant Taylor via TUHS
2021-01-27  6:19                                   ` Henry Bent
2021-01-27  7:28                                   ` Jon Steinhart
2021-01-27 10:02                                   ` Dave Horsfall
2021-01-27 18:32                                   ` Grant Taylor via TUHS
2021-01-27 19:26                                     ` Nemo Nusquam
2021-01-27 15:47                               ` Larry McVoy
2021-01-27 16:40                                 ` Stephen Clark
2021-01-26  2:45                           ` John Cowan
2021-01-27 19:34                             ` Nemo Nusquam
2021-01-29 22:02                             ` Dave Horsfall
2021-01-30  1:50                               ` Nemo Nusquam
2021-01-31  2:42                                 ` Dave Horsfall
2021-01-30  3:51                               ` Richard Salz
2021-01-30 23:20                                 ` John Cowan
2021-01-25 15:48                       ` Henry Bent
2021-01-25 14:33                   ` Clem Cole
2021-01-24 23:50             ` Ed Carp
2021-01-24 21:29       ` Al Kossow
2021-01-24 21:53       ` Lars Brinkhoff
2021-02-14  2:04       ` Greg A. Woods
2021-02-14  2:49         ` Jon Steinhart
2021-02-14  4:53           ` Rich Morin
2021-01-24 18:41   ` Toby Thain
2021-01-24 18:24 ` Dan Cross
2021-01-24 18:42   ` arnold
2021-01-24 19:11     ` Larry McVoy
2021-01-24 21:07 ` Rich Morin
2021-01-24 21:10   ` Ronald Natalie
2021-01-24 22:30     ` Rich Morin
2021-01-24 21:16   ` Jon Steinhart
2021-01-28  2:48 Norman Wilson
2021-01-28  9:24 Noel Chiappa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9727.1611618394@hop.toad.com \
    --to=gnu@toad.com \
    --cc=crossd@gmail.com \
    --cc=tuhs@minnie.tuhs.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).