From owner-freebsd-hackers Fri Nov 13 09:25:50 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id JAA04584 for freebsd-hackers-outgoing; Fri, 13 Nov 1998 09:25:50 -0800 (PST) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from apollo.backplane.com (apollo.backplane.com [209.157.86.2]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id JAA04577 for ; Fri, 13 Nov 1998 09:25:48 -0800 (PST) (envelope-from dillon@apollo.backplane.com) Received: (from dillon@localhost) by apollo.backplane.com (8.9.1/8.9.1) id JAA05134; Fri, 13 Nov 1998 09:25:22 -0800 (PST) (envelope-from dillon) Date: Fri, 13 Nov 1998 09:25:22 -0800 (PST) From: Matthew Dillon Message-Id: <199811131725.JAA05134@apollo.backplane.com> To: Dru Nelson Cc: freebsd-hackers@FreeBSD.ORG Subject: Re: write syscall times for sockets References: Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG :Hi, : : I wrote a simple C program to guage how many usec's : system calls take or write calls take for various : write lengths. : : I setup a socket to the discard socket on another machine. : I did various writes. The times are in the attachment. : The first 4 writes are 0,0,8,?. After that all the writes : are in groups of 4 with a sleep(2) in between. : Ahh.. :-) I'll just include the code. : : Basically, the first system call would take longer for some : reason. Then each write would be pretty consistent. Well, amoung other things, the system must initially fault the buffer into memory, whether it's zero-page or not. : What I was looking for was that characteristic of writing : to a socket with buffer available. The call should be pretty In order to test this properly you also need to take into account the TCP window size and kernel buffering. The combination determines how much unacked data the destination is willing to accept and how much data the source is willing to buffer in the kernel. You can control the parameter somewhat on the source with a socket option SO_SNDBUF and SO_SNDLOWAT (see 'setsockopt'), you can set system-wide defaults with sysctl (sysctl -a | fgrep tcp), and you can set per-route specifics with route (e.g. route -n get default; route -n change default -sendpipe 60000, and so on). For the tests you are making, it should be sufficient to set it just on the sender's side. You might also be interested in the new sendfile() functionality just recently added by David Greenman to FreeBSD. -Matt : This is pretty much for fun... a limited test case. However, : I think the information would be interesting. : : I'm not on this list, so if you could cc: me when you reply, : that would be great. : :Dru Nelson :Redwood City, California Matthew Dillon Engineering, HiWay Technologies, Inc. & BEST Internet Communications & God knows what else. (Please include original email in any response) To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message