*BSD News Article 28255


Return to BSD News archive

Path: sserve!newshost.anu.edu.au!munnari.oz.au!foxhound.dsto.gov.au!fang.dsto.gov.au!yoyo.aarnet.edu.au!news.adelaide.edu.au!news.cs.su.oz.au!metro!ultima!kralizec.zeta.org.au!godzilla.zeta.org.au!not-for-mail
From: bde@kralizec.zeta.org.au (Bruce Evans)
Newsgroups: comp.os.386bsd.questions
Subject: Re: linux's I/O calls faster than NetBSD's ?
Date: 11 Mar 1994 01:12:47 +1100
Organization: Kralizec Dialup Unix Sydney - +61-2-837-1183, v.32bis and v.42bis
Lines: 86
Message-ID: <2ln9svINNct@godzilla.zeta.org.au>
References: <2lhv9r$pbt@homea.ensta.fr> <JY2Invr.dysonj@delphi.com>
NNTP-Posting-Host: godzilla.zeta.org.au

In article <JY2Invr.dysonj@delphi.com>, John Dyson  <dysonj@delphi.com> wrote:
>Manuel Bouyer <bouyer@bsdtest.ensta.fr> writes:
> 
>>We have made some comparaisons between NetBSD 0.9 and Linux, and it appears that 
>>Linux's disk i/o calls are much faster in some case (time gives 4 seconds versus 4
>>minutes for a programs which make direct acces writing and reading on a file, on
>>exactly the same hardware).
> 
>Would you post your benchmark so we can check it out????  NetBSD does

Check out these:
---
main()
{
    int i;

    for (i = 0; i < 10000; ++i)
    {
	int fd;

	fd = creat("z", 0666);
	close(fd);
	unlink("z");
    }
}
---
On a 486DX2/66 with an Ultrastor 34F controller this takes 3.87 seconds
under Linux-0.99.15g (ext2fs) and 667 seconds under FreeBSD-1.1-BETA
(ufs) because ufs writes important directory changes immediately and in
a robust order.  This is hard to fix properly.  Many people consider
that non-robust directory updates would be worse than abysmally slow
directory updates.

---
main()
{
    int i;
    char buf[8192];

    for (i = 0; i < 10000; ++i)
    {
	write(1, buf, sizeof buf);
	lseek(1, 0L, 0);
    }
}
---
With output redirected to a disk file, this takes 4.74 seconds under
linux and 166.75 under FreeBSD, because FreeBSD writes blocks fairly
soon after they fill up.  I've been running the following fix for it
for over a year.
---
*** ufs_vnops.c~	Thu Jan 20 08:09:12 1994
--- ufs_vnops.c	Mon Mar  7 23:02:20 1994
***************
*** 617,624 ****
  		if (ioflag & IO_SYNC)
  			(void) bwrite(bp);
  		else if (n + on == fs->fs_bsize) {
  			bp->b_flags |= B_AGE;
  			bawrite(bp);
! 		} else
  			bdwrite(bp);
  		ip->i_flag |= IUPD|ICHG;
--- 617,627 ----
  		if (ioflag & IO_SYNC)
  			(void) bwrite(bp);
+ #if 0 /* write-through when the block fills up is sloooow */
  		else if (n + on == fs->fs_bsize) {
  			bp->b_flags |= B_AGE;
  			bawrite(bp);
! 		}
! #endif
! 		else
  			bdwrite(bp);
  		ip->i_flag |= IUPD|ICHG;
---

Manuel Bouyer posted a benchmark involving random access and fwrites.
The `n + on == fs->fs_bsize' test is supposed to avoid write-through
for most random-access writes.  However, stdio's buffering policies
bad for special cases, and if the write size is a full block then
write-through is slower by a factor of almost the average number of
times each block is written (since writing to the cache is much
faster than writing to disk).
-- 
Bruce Evans  bde@kralizec.zeta.org.au