From: Helge Hafting <helgehaf@aitel.hist.no>
To: erik@hensema.net
Cc: linux-kernel@vger.kernel.org
Subject: Re: Delaying writes to disk when there's no need
Date: Thu, 27 Mar 2003 10:06:53 +0100 [thread overview]
Message-ID: <3E82BF2D.8080508@aitel.hist.no> (raw)
In-Reply-To: slrnb843gi.2tt.usenet@bender.home.hensema.net
Erik Hensema wrote:
> In all kernels I've tested writes to disk are delayed a long time even when
> there's no need to do so.
>
Short answer - it is supposed to do that!
> A very simple test shows this: on an otherwise idle system, create a tar of
> a NFS-mounted filesystem to a local disk. The kernel starts writing out the
> data after 30 seconds, while a slow and steady stream would be much nicer
> to the system, I think.
>
You're wrong then. There's no need for a slow steady stream, why do
you want that. Of course you can set up cron to run sync at
regular (short) intervals to achieve this.
> On 2.4.x this can block the system for several seconds. 2.5.6x and
> 2.5.6x-mm (with AS) also show this behaviour, but the system doesn't block
> anymore. I'm using a preemtable kernel.
>
Writing out stuff is not supposed to block the machine, and as you say,
it is fixed in 2.5. No need for the steady writing.
> I only started to notice this behaviour when I upgraded from 256 MB ram to
> 512 MB. In other words: Linux behaves more nicely with 256 MB.
>
Why do you think that is more nice?
Writing is delayed because that accumulate bigger writes and
fewer seeks. This helps performance a lot. Delaying writes
has another advantage - somw writes won't be done at all,
saving 100% writing time. This is the case for temporary
files that gets written to, read, and deleted before they
get written to disk. It all happens in cache, improving
performance tremendously. To see the alternative,
try booting with mem=4M or 16M or some such, with _no_ swapping.
Another case is a file that gets overwritten several times.
This all happens in memory because of the delay, only the final
version gets written to disk. This is ver common, even for files
that are written only once. (slowly extending a file
and writing it to disk every time _will_ write the same stuff
over and over because it is impossible to add a few bytes only.
You always write a whole block, adding anything less than that
involves reading the half-full block, updating it, and writing it
back. Keeping such operations in memory saves quite a few
disk writes.)
For more detailed information, read a book about how filesystems and
disk caching works.
Helge Hafting
next prev parent reply other threads:[~2003-03-27 8:53 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-03-26 20:31 Delaying writes to disk when there's no need Erik Hensema
2003-03-27 9:06 ` Helge Hafting [this message]
2003-03-27 11:22 ` Erik Hensema
2003-03-28 23:12 ` Pavel Machek
2003-03-31 12:00 ` Erik Hensema
2003-03-31 13:42 ` Helge Hafting
2003-03-31 14:45 ` Oliver Neukum
2003-03-31 22:02 ` Nick Piggin
2003-03-31 22:22 ` Chris Friesen
2003-03-31 22:35 ` Nick Piggin
2003-03-31 22:51 ` John Bradford
2003-03-31 22:58 ` Nick Piggin
2003-03-31 22:45 ` Andrew Morton
2003-03-31 23:03 ` Nick Piggin
2003-03-31 23:32 ` Ingo Oeser
2003-04-01 0:02 ` Andrew Morton
2003-04-01 0:43 ` Daniel Pittman
2003-04-01 1:09 ` Andrew Morton
2003-04-01 1:34 ` Daniel Pittman
2003-04-01 1:45 ` Andrew Morton
[not found] ` <3E88EB3D.6020409@cyberone.com.au>
2003-04-01 1:39 ` Andrew Morton
[not found] <20030326204012$188c@gated-at.bofh.it>
[not found] ` <20030327091007$22a5@gated-at.bofh.it>
[not found] ` <20030327113014$37b4@gated-at.bofh.it>
2003-03-28 10:18 ` Tim Connors
2003-03-30 17:38 ` Helge Hafting
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3E82BF2D.8080508@aitel.hist.no \
--to=helgehaf@aitel.hist.no \
--cc=erik@hensema.net \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.