Article View: comp.arch
Article #13346Re: String Processing Instruction
From: rpw3
Date: Tue, 31 Mar 1987 05:51
Date: Tue, 31 Mar 1987 05:51
53 lines
2994 bytes
2994 bytes
In article <238@winchester.mips.UUCP> mash@winchester.UUCP (John Mashey) writes:
>Following are the stats for SYS V : ls -l /usr
> cycles %cycles cum % cycles bytes procedure (file)
> /call /line
> 511480 44.87 44.87 6558 22 getname (ls.c)
> 310413 27.23 72.11 16 40 fgetc (../fgetc.c)
> 99006 8.69 80.79 43 28 _flsbuf (../flsbuf.c)
> 79820 7.00 87.80 340 17 _doprnt (../doprnt.c)
> ... ... ... ... ... ...
Hey, John, wanna know something really interesting? Go look at 4.2 BSD
"ls", at routine getname(), and you'll discover it's full of getpwent()'s
(plus {set,end}pwent(), etc.) and strncpy()'s (hidden in the "SCPYN" macro).
And of course getpwent() uses the str* routines, though it also has its
own pwskip() instead if index(). (Have you got a 4.{2,3} BSD "ls" that you
could run your profiler on?)
Then look at the Sys V "ls", and lo & behold, all of those neat library
routines have been unfolded into the getname() routine, and hand-coded
into a most glorious mess, which calls only (guess)... fgetc()!!!
(No wonder my jaw dropped when I saw your numbers!)
Now other parts of Sys V use {set,get,end}pwent(), so I guess somebody
decided that "ls" was running too slow (or had an "intuition"?) and ripped
it apart. Given the looks of the code, I'm surprised that even fgetc()
survived.
This reminds me of Gerry Weinberg's "Railroad Paradox":
"We don't need fast strlib routines, because no one ever uses them."
Yeah... 'cause they're not fast, everyone codes around them!
We (me, too, I just realized I got suckered in also) must be *VERY* careful
to look inside any major piece of code we are going to try and use to prove
something or other, in order to avoid simply confirming the {good,bad,weird}
practices of the past.
I am now completely unsure whether we can get ANY reasonable statistics on
what the proper usage (percent, etc.) of "str*" should/could be in NEW code,
if we base it on code that has been hacked on as long as the various Unices.
Anybody want to cough up a "Stryngstone" benchmark for us to throw rocks at?
Rob Warnock
Systems Architecture Consultant
UUCP: {amdcad,fortune,sun,attmail}!redwood!rpw3
ATTmail: !rpw3
DDD: (415)572-2607
USPS: 627 26th Ave, San Mateo, CA 94403
Technical Details
Message-ID:
<15332@amdcad.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!water!watnot!watmath!clyde!rutgers!ames!ucbcad!ucbvax!amdcad!rpw3References:
<15292@amdcad.UUCP> <978@ames.UUCP> <15304@amdcad.UUCP>Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: arc1-ca.pugleaf.net!utzoo!utgpu!water!watnot!watmath!clyde!rutgers!ames!ucbcad!ucbvax!amdcad!rpw3 From: rpw3@amdcad.UUCP Newsgroups: comp.arch,comp.lang.c Subject: Re: String Processing Instruction Message-ID: <15332@amdcad.UUCP> Date: Tue, 31-Mar-87 00:51:02 EST Article-I.D.: amdcad.15332 Posted: Tue Mar 31 00:51:02 1987 Date-Received: Thu, 2-Apr-87 00:54:21 EST References: <15292@amdcad.UUCP> <978@ames.UUCP> <15304@amdcad.UUCP> Reply-To: rpw3@amdcad.UUCP (Rob Warnock) Distribution: na Organization: [Consultant] San Mateo, CA Lines: 53