From owner-freebsd-current@FreeBSD.ORG Thu Aug 4 19:04:44 2005 Return-Path: X-Original-To: current@freebsd.org Delivered-To: freebsd-current@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0282916A41F; Thu, 4 Aug 2005 19:04:44 +0000 (GMT) (envelope-from PeterJeremy@optushome.com.au) Received: from mail07.syd.optusnet.com.au (mail07.syd.optusnet.com.au [211.29.132.188]) by mx1.FreeBSD.org (Postfix) with ESMTP id DEBA343D46; Thu, 4 Aug 2005 19:04:42 +0000 (GMT) (envelope-from PeterJeremy@optushome.com.au) Received: from cirb503493.alcatel.com.au (c220-239-19-236.belrs4.nsw.optusnet.com.au [220.239.19.236]) by mail07.syd.optusnet.com.au (8.12.11/8.12.11) with ESMTP id j74J4X9C004585 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO); Fri, 5 Aug 2005 05:04:35 +1000 Received: from cirb503493.alcatel.com.au (localhost.alcatel.com.au [127.0.0.1]) by cirb503493.alcatel.com.au (8.12.10/8.12.10) with ESMTP id j74J4XSR002855; Fri, 5 Aug 2005 05:04:33 +1000 (EST) (envelope-from pjeremy@cirb503493.alcatel.com.au) Received: (from pjeremy@localhost) by cirb503493.alcatel.com.au (8.12.10/8.12.9/Submit) id j74J4WuP002854; Fri, 5 Aug 2005 05:04:32 +1000 (EST) (envelope-from pjeremy) Date: Fri, 5 Aug 2005 05:04:32 +1000 From: Peter Jeremy To: David Malone Message-ID: <20050804190432.GA2104@cirb503493.alcatel.com.au> References: <42F0CCD5.9090200@portaone.com> <20050803150117.GD93405@dan.emsphone.com> <42F0E9B2.9080208@portaone.com> <20050804060251.GA21228@nagual.pp.ru> <20050804063908.GA21871@nagual.pp.ru> <20050804075711.GB271@cirb503493.alcatel.com.au> <20050804092637.GA12561@walton.maths.tcd.ie> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20050804092637.GA12561@walton.maths.tcd.ie> User-Agent: Mutt/1.4.2i Cc: Dan Nelson , Maxim.Sobolev@portaone.com, "current@freebsd.org" Subject: Re: Sub-optimal libc's read-ahead buffering behaviour X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Aug 2005 19:04:44 -0000 On Thu, 2005-Aug-04 10:26:37 +0100, David Malone wrote: >On Thu, Aug 04, 2005 at 05:57:11PM +1000, Peter Jeremy wrote: >> That said, I've seen similar behaviour on other systems so it could be >> a subtle side-effect of POSIX. > >There are some magic things about fseek in the C standard - I wonder >if this could be related to them. For example (from C99) in the >commentry on fopen: [read/write switching] I don't see anything there that mandates the existing behaviour. The existing behaviour may be a simple way to implement the requirements but a more efficient way would seem to be to use flags to allow read/write switching and only reload the buffer if the next I/O operation specifies a different direction to the previous one. >Could what stdio is doing be related to flushing ungetc? The ungetc buffer is separate to the normal I/O buffer. Flushing it shouldn't require the normal I/O buffer to be re-read. -- Peter Jeremy