From owner-freebsd-hackers Wed Feb 28 5:59:40 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from hda.hda.com (host65.hda.com [63.104.68.65]) by hub.freebsd.org (Postfix) with ESMTP id 0BEB737B718 for ; Wed, 28 Feb 2001 05:59:35 -0800 (PST) (envelope-from dufault@hda.hda.com) Received: (from dufault@localhost) by hda.hda.com (8.11.1/8.11.1) id f1SDvVW27830; Wed, 28 Feb 2001 08:57:31 -0500 (EST) (envelope-from dufault) From: Peter Dufault Message-Id: <200102281357.f1SDvVW27830@hda.hda.com> Subject: Re: how to actually find out whether data hit the disk? In-Reply-To: <20010228140749.B29400@heechee.tobez.org> from Anton Berezin at "Feb 28, 2001 02:07:49 pm" To: Anton Berezin Date: Wed, 28 Feb 2001 08:57:31 -0500 (EST) Cc: hackers@FreeBSD.ORG X-Mailer: ELM [version 2.4ME+ PL61 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > I am doing the following, on the partition with softupdates turned on: > > 1. fd = open("a file", O_CREAT) > 2. mmap(fd) > 3. sequencial write to mmapped region > 4. some other processing > 5. munmap > 6. unlink > 7. close > > Since this is a supposedly high-perfomance application, I am interested > that data do NOT hit the disk. I understand that softupdates do a good > job at that. The time taken by step 4 is usually sub-second, but > sometimes it can take longer (network delays etc.). The question is - > is it possible to actually find out whether data hit the disk or not for > a particular run of 1-7? Answer to your question: Do an msync with MS_SYNC someplace. Also, use MAP_NOSYNC in mmap until 4.3 when Matt Dillon plans to make that the default behavior. But: When does the data need to "hit the disk", given that you're unlinking the file in step 6? If I read the posix spec correctly it may never need to hit the disk. Consider a set of unrelated processes whacking a shared memory file. Set it up so the first one creates it, a bunch attach, and a final one attaches and unlinks it: process 1: fd = open("foo", O_CREAT|O_RDWR); mmap(fd, MAP_NOSYNC|MAP_SHARED); Write to mapped region process 2: fd = open("foo", O_RDWR); mmap(fd, MAP_NOSYNC|MAP_SHARED); process 3: fd = open("foo", O_RDWR); mmap(fd, MAP_NOSYNC|MAP_SHARED); ... process N: fd = open("foo", O_RDWR) mmap(fd, MAP_NOSYNC|MAP_SHARED); unlink("foo"); Everyone now happily does what they want and then all exit and no one ever does an msync(). Then you never need to actually transfer any data to disk. I'm not sure what actually happens now. Peter -- Peter Dufault (dufault@hda.com) Realtime development, Machine control, HD Associates, Inc. Fail-Safe systems, Agency approval To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message