All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@zip.com.au>
To: Linus Torvalds <torvalds@transmeta.com>
Cc: lkml <linux-kernel@vger.kernel.org>
Subject: [patch 5/16] speed up writes
Date: Sat, 01 Jun 2002 01:41:47 -0700	[thread overview]
Message-ID: <3CF888CB.FF93908E@zip.com.au> (raw)



Speeds up generic_file_write() by not calling mark_inode_dirty() when
the mtime and ctime didn't change.

There may be concerns over the fact that this restricts mtime and ctime
updates to one-second resolution.  But the interface doesn't support
that anyway - all the filesystem knows is that its dirty_inode()
superop was called.  It doesn't know why.

So filesystems which support high-resolution timestamps already need to
make their own arrangements.  We need an update_mtime i_op to support
those properly.

time to write a one megabyte file one-byte-at-a-time:

Before:
	ext3:		24.8 seconds
	ext2:		 4.9 seconds
	reiserfs:	17.0 seconds
After:
	ext3:		22.5 seconds
	ext2:		4.8  seconds
	reiserfs:	11.6 seconds

Not much improvement because we're also calling expensive
mark_inode_dirty() functions when i_size is expanded.  So compare the
overwrite case:

time dd if=/dev/zero of=foo bs=1 count=1M conv=notrunc

ext3 before:	20.0 seconds
ext3 after:	9.7  seconds


=====================================

--- 2.5.19/mm/filemap.c~mtime-speedup	Sat Jun  1 01:18:08 2002
+++ 2.5.19-akpm/mm/filemap.c	Sat Jun  1 01:18:08 2002
@@ -2098,6 +2098,7 @@ generic_file_write(struct file *file, co
 	ssize_t		written;
 	int		err;
 	unsigned	bytes;
+	time_t		time_now;
 
 	if (unlikely((ssize_t) count < 0))
 		return -EINVAL;
@@ -2195,9 +2196,12 @@ generic_file_write(struct file *file, co
 		goto out;
 
 	remove_suid(file->f_dentry);
-	inode->i_ctime = CURRENT_TIME;
-	inode->i_mtime = CURRENT_TIME;
-	mark_inode_dirty_sync(inode);
+	time_now = CURRENT_TIME;
+	if (inode->i_ctime != time_now || inode->i_mtime != time_now) {
+		inode->i_ctime = time_now;
+		inode->i_mtime = time_now;
+		mark_inode_dirty_sync(inode);
+	}
 
 	if (unlikely(file->f_flags & O_DIRECT)) {
 		written = generic_file_direct_IO(WRITE, file,

-

                 reply	other threads:[~2002-06-01  8:39 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=3CF888CB.FF93908E@zip.com.au \
    --to=akpm@zip.com.au \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@transmeta.com \
    /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.