[news.software.b] C news vs B news speed

david@elroy.jpl.nasa.gov (David Robinson) (07/10/89)

Henry pointed out that there is not much you can do to newsrun to
speed it up without breaking it's robustness.  I agree, but you
can tweek it a bit for added performence.  The first and biggest is
to comment out the  c7decode lines if you never expect to get encoded
news.  The other thing I have done which helps if you get many small
batches (ie from a once a minute NNTP sender) is to rewrite 'spacefor'
and 'sizeof' into C if you can.  Both are trivial to write but you
may need a statfs() system call for the former.  This reduces the
numerous ls, df, and awk calls.

I do agree that C news is considerably faster, our Sun-2 had just stepped
over the brink and was not able to keep up with the volume, with C news
it has been given a reprise.

	-David
-- 
	David Robinson		elroy!david@csvax.caltech.edu     ARPA
				david@elroy.jpl.nasa.gov	  ARPA
				{cit-vax,ames}!elroy!david	  UUCP
Disclaimer: No one listens to me anyway!

henry@utzoo.uucp (Henry Spencer) (07/13/89)

In article <1989Jul9.223927.29156@elroy.jpl.nasa.gov> david@elroy.jpl.nasa.gov (David Robinson) writes:
>... tweek it a bit for added performence.  The first and biggest is
>to comment out the  c7decode lines if you never expect to get encoded
>news...

At some point conf/build will probably be modified slightly to at least
suggest doing that.  The c7decode stuff is kind of specialized.

>The other thing I have done which helps if you get many small
>batches (ie from a once a minute NNTP sender) is to rewrite 'spacefor'
>and 'sizeof' into C if you can.  Both are trivial to write but you
>may need a statfs() system call for the former...

I'm contemplating doing some of this myself, in fact, although if I do
use C for spacefor, it will probably popen("df") to do the actual space
finding -- that job is just too system-dependent.
-- 
$10 million equals 18 PM       |     Henry Spencer at U of Toronto Zoology
(Pentagon-Minutes). -Tom Neff  | uunet!attcan!utzoo!henry henry@zoo.toronto.edu

pim@ctisbv.UUCP (Pim Zandbergen) (07/14/89)

In article <1989Jul12.210254.8631@utzoo.uucp> henry@utzoo.uucp (Henry Spencer) writes:

[ about rewriting spacefor in C ]

>I'm contemplating doing some of this myself, in fact, although if I do
>use C for spacefor, it will probably popen("df") to do the actual space
>finding -- that job is just too system-dependent.

The following works for me on
AT&T System V/386 r 3.2,
System V r 3.1.1 on the AT&T 3B2,
SCO Xenix,
Microport System V/AT,
AIX for the IBM PC RT.
_______________________________________________________________________________
#include	<sys/types.h>
#include	<sys/stat.h>
#include	<ustat.h>

main()
{
	struct stat	statbuf;
	struct ustat	ustatbuf;

	if (stat("/usr/spool/news", &statbuf) < 0)
	{
		perror("cannot fstat");
		exit(1);
	}
	if (ustat(statbuf.st_dev, &ustatbuf) < 0)
	{
		perror("cannot ustat");
		exit(1);
	}
	printf("%ld free blocks\n", (long)(ustatbuf.f_tfree));
	printf("%ld free inodes\n", (long)(ustatbuf.f_tinode));
}
_______________________________________________________________________________

It should be noted, however, that this program reports
the real number of free blocks, which is not necessarely
in 512 byte units. I know of no system call that reports
the blocksize of a filesystem *and* is present in all the
mentioned flavours of System V (no statfs(2) in AIX nor in uPort V/AT).
-- 
--------------------+----------------------+-----------------------------------
Pim Zandbergen      | phone: +31 70 542302 | CTI Software BV
pim@ctisbv.UUCP     | fax  : +31 70 512837 | Laan Copes van Cattenburch 70
...!uunet!mcvax!hp4nl!ctisbv!pim           | 2585 GD The Hague, The Netherlands

yun@cinnet.COM (Yun-seng Chao) (07/14/89)

From article <1989Jul12.210254.8631@utzoo.uucp>, by henry@utzoo.uucp (Henry Spencer):
> In article <1989Jul9.223927.29156@elroy.jpl.nasa.gov> david@elroy.jpl.nasa.gov (David Robinson) writes:
>>The other thing I have done which helps if you get many small
>>batches (ie from a once a minute NNTP sender) is to rewrite 'spacefor'
>>and 'sizeof' into C if you can.  Both are trivial to write but you
>>may need a statfs() system call for the former...
> 
> I'm contemplating doing some of this myself, in fact, although if I do
> use C for spacefor, it will probably popen("df") to do the actual space
> finding -- that job is just too system-dependent.

Uh, wasn't there something called "bdf" posted last year that was able to
parse the Sys V "df" command?  Why not use some of that code for usg
systems to do some of this parsing (with acknowledgements to the original
author, of course)?
-- 
------------------------------------------------------------
Yun-seng Chao                Cincinnati Network
cinnet!yun                   Voice # (513) 777-5614

henry@utzoo.uucp (Henry Spencer) (07/14/89)

In article <781@ctisbv.UUCP> pim@ctisbv.UUCP (Pim Zandbergen) writes:
>>... it will probably popen("df") to do the actual space
>>finding -- that job is just too system-dependent.
>
>The following works for me on
>AT&T System V/386 r 3.2,
>System V r 3.1.1 on the AT&T 3B2,
>SCO Xenix,
>Microport System V/AT,
>AIX for the IBM PC RT.

All of them more or less System V based.  That's not all there is to the
Unix world, I'm afraid.  Of particular note are the systems that are old
enough that they have *no* system call to ask about free space (df paws
through the raw filesystems).
-- 
$10 million equals 18 PM       |     Henry Spencer at U of Toronto Zoology
(Pentagon-Minutes). -Tom Neff  | uunet!attcan!utzoo!henry henry@zoo.toronto.edu

jmm@ecijmm.UUCP (John Macdonald) (07/18/89)

In article <1018@cniysc.cinnet.COM> yun@cinnet.COM (Yun-seng Chao) writes:
|
|Uh, wasn't there something called "bdf" posted last year that was able to
|parse the Sys V "df" command?  Why not use some of that code for usg
|systems to do some of this parsing (with acknowledgements to the original
|author, of course)?

"bdf" was a perl program that converted Sys V df output into a format
similar to Berkely df.  I kind of doubt that Henry and Geoff would want
to include perl as a pre-requisite for C news.
-- 
John Macdonald

pjh@mccc.UUCP (Pete Holsberg) (07/21/89)

In article <297@ecijmm.UUCP> jmm@ecijmm.UUCP (John Macdonald) writes:
=In article <1018@cniysc.cinnet.COM> yun@cinnet.COM (Yun-seng Chao) writes:
=|
=|Uh, wasn't there something called "bdf" posted last year that was able to
=|parse the Sys V "df" command?  Why not use some of that code for usg
=|systems to do some of this parsing (with acknowledgements to the original
=|author, of course)?
=
="bdf" was a perl program that converted Sys V df output into a format
=similar to Berkely df.  I kind of doubt that Henry and Geoff would want
=to include perl as a pre-requisite for C news.
=-- 
=John Macdonald

I just cat'd the bdf I have and it's a binary file.  I guess there must
be two bdf's.

-- 
Pete Holsberg -- Mercer College -- Trenton, NJ 08690
...!rutgers!njin!princeton!njsmu!mccc!pjh