From: andersen@marvin.ama.ttu.edu (Kim Andersen)
Newsgroups: comp.sys.sgi
Subject: re: IP12 client nfs slow
Date: 8 Oct 92 16:00:22 GMT

In article <1992Oct6.073123.15209@crow.omni.co.jp> Timothy Richards 
<trich@crow.omni.co.jp> writes:

> I have been somewhat suspicious of the ethernet performance on
> 4D series machines with IP12 cpus.
>
> The results seem to show that nfs is very slow from the IP12
> machines.  The measurements were taken when the network usage
> was very low.

There is a known bug in 4.0.1 which doesn't handle the IP12 ethernet chip
properly (or something).  Compile and run this program in background as root.
Your nfs performance should increase at least tenfold.

This problem is supposed to be fixed in 4.0.5.

/*
PROGRAM nfsfix.c

Here is the program to fix the incredible-slowness problem of NFS under
4.0.1 on IP12 and IP17 machines.  I got it from Georges Lauri at Berkeley.
It speeded up my NFS transfers on 4.0.1 from 30sec/250KB to 2sec/250KB.
Your mileage may vary.

Compile this program, and run it as root in background.

This is a software patch to a hardware bug. The software patch
is part of 4.0.5, so call SGI and get on their list to get 4.0.5
when 4.0.5a ships. SGI also has fixed the chip for future systems.

This only works on IP12 and IP17 machines (Indigo, PI, Crimson).  It
has to be run from root as a daemon - try letting it run in the
background and then testing NFS performance. If that doesn't help, you
may have a more serious networking problem.

You can make sure that it's running properly by doing a netstat 1; the
count of received packets will be much higher when it's running (if
your net is at all busy).

Put this in /usr/etc and add it to /etc/init.d/network.local to 
run it at boot (in background).  If you don't have a network.local, 
read /etc/init.d/network (search on local) to find instructions for
setting up the linking to the boot files, and copy the following to 
/etc/init.d/network.local: 

#! /bin/sh
#  local network initialization/shutdown
#
case "$1" in
'start')
    /usr/etc/nfsfix &
    ;;
'stop')
    ;;
*)
    echo "usage: $0 {start|stop}"
    ;;
esac
*/

#include <limits.h>
#include <unistd.h>
#include <sys/types.h>
#include <net/raw.h>
#include <netinet/if_ether.h>

#define ETHERHDRPAD     RAW_HDRPAD(sizeof(struct ether_header))

        struct etherpacket {
                struct snoopheader      snoop;
                char                    pad[ETHERHDRPAD];
                struct ether_header     ether;
                char                    data[ETHERMTU];
        };

main()
{
        int s;
        struct sockaddr_raw sr;
        struct snoopfilter sf;
        int cc = 60000, on = 1;
        struct etherpacket ep;

        s = socket(PF_RAW, SOCK_RAW, RAWPROTO_SNOOP);
        sr.sr_family = AF_RAW;
        sr.sr_port = 0;
        strncpy(sr.sr_ifname, "ec0", sizeof sr.sr_ifname);
        bind(s, &sr, sizeof sr);

        bzero((char *) &sf, sizeof sf);
        ioctl(s, SIOCADDSNOOP, &sf);

        setsockopt(s, SOL_SOCKET, SO_RCVBUF, (char *) &cc, sizeof cc);
        ioctl(s, SIOCSNOOPING, &on);
        sleep(90000000);
}




Kim Andersen
Crystallography
Harrington Cancer Center
andersen@marvin.ama.ttu.edu