From: Chris Mason <chris.mason@oracle.com>
To: "Theodore Ts'o" <tytso@mit.edu>, Ric Wheeler <rwheeler@redhat.com>
Cc: Linux Kernel Developers List <linux-kernel@vger.kernel.org>,
Ext4 Developers List <linux-ext4@vger.kernel.org>,
jack@suse.cz
Subject: Re: [PATCH 0/3] Ext3 latency improvement patches
Date: Fri, 27 Mar 2009 16:50:31 -0400 [thread overview]
Message-ID: <1238187031.27455.212.camel@think.oraclecorp.com> (raw)
In-Reply-To: <1238185471-31152-1-git-send-email-tytso@mit.edu>
[-- Attachment #1: Type: text/plain, Size: 905 bytes --]
On Fri, 2009-03-27 at 16:24 -0400, Theodore Ts'o wrote:
> The following patches have been posted as providing at least some
> partial improvement to the ext3 latency problem that has been
> discussed on the 2.6.29 mongo-LKML-thread-that-would-not-die.
Ric had asked me about a test program that would show the worst case
ext3 behavior. So I've modified your ext3 program a little. It now
creates a 8G file and forks off another proc to do random IO to that
file.
Then it runs one fsync every 4 seconds and times how long they take.
After the program has been running for 60 seconds, it tries to stop.
On my sata drive with barriers on, even btrfs and xfs saw some
multi-second fsyncs, but ext3 came in at 414s for a single fsync.
Warning: don't run this on a laptop drive, you'll still be waiting for
it next year. This is probably full of little errors, I cut it together
pretty quickly.
-chris
[-- Attachment #2: fsync-tester.c --]
[-- Type: text/x-csrc, Size: 2793 bytes --]
/*
* fsync-tester.c
*
* Written by Theodore Ts'o, 3/21/09. Updated by Chris Mason to include
* the random writer thread
*
* This file may be redistributed under the terms of the GNU Public
* License, version 2.
*/
#define _FILE_OFFSET_BITS 64
#define _XOPEN_SOURCE 500
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/wait.h>
#include <signal.h>
#include <time.h>
#include <fcntl.h>
#include <string.h>
#define SIZE (32768*32)
static char bigbuf[4096];
static float timeval_subtract(struct timeval *tv1, struct timeval *tv2)
{
return ((tv1->tv_sec - tv2->tv_sec) +
((float) (tv1->tv_usec - tv2->tv_usec)) / 1000000);
}
static void random_io(int fd, loff_t total)
{
loff_t cur = 0;
int ret;
/* just some constant so our runs are always the same */
srand(4096);
while(1) {
/*
* we want a random offset into the file,
* but rand only returns max in. So we make
* it a random block number instead, and multiply
* by 4096.
*/
cur = rand();
cur = (cur * 4096) % (total - 4096);
/* align our offset to 4k */
cur = cur / 4096;
cur = cur * 4096;
ret = pwrite(fd, bigbuf, 4096, cur);
if (ret < 4096) {
fprintf(stderr, "short write ret %d cur %llu\n",
ret, (unsigned long long)cur);
exit(1);
}
}
}
int main(int argc, char **argv)
{
int fd;
struct timeval tv, tv2, start;
char buf[SIZE];
pid_t pid;
loff_t total = ((loff_t)8) * 1024 * 1024 * 1024;
loff_t cur = 0;
int rand_fd;
int ret;
int i;
int status;
struct stat st;
memset(bigbuf, 0, 4096);
rand_fd = open("fsync-tester.rnd-file", O_WRONLY|O_CREAT);
if (rand_fd < 0) {
perror("open");
exit(1);
}
ret = fstat(rand_fd, &st);
if (ret < 0) {
perror("fstat");
exit(1);
}
if (st.st_size < total) {
printf("setting up random write file\n");
while(cur < total) {
ret = write(rand_fd, bigbuf, 4096);
if (ret <= 0) {
fprintf(stderr, "short write\n");
exit(1);
}
cur += ret;
}
printf("done setting up random write file\n");
}
fd = open("fsync-tester.tst-file", O_WRONLY|O_CREAT);
if (fd < 0) {
perror("open");
exit(1);
}
memset(buf, 'a', SIZE);
pid = fork();
if (pid == 0) {
printf("starting random io!\n");
random_io(rand_fd, total);
exit(0);
}
close(rand_fd);
gettimeofday(&start, NULL);
printf("starting fsync run\n");
for(i = 0; i < 60; i++) {
pwrite(fd, buf, SIZE, 0);
gettimeofday(&tv, NULL);
fsync(fd);
gettimeofday(&tv2, NULL);
printf("fsync time: %5.4fs\n", timeval_subtract(&tv2, &tv));
if (timeval_subtract(&tv2, &start) > 60)
break;
sleep(4);
}
printf("run done %d fsyncs total, killing random writer\n", i + 1);
fflush(stdout);
kill(pid, SIGTERM);
wait(&status);
return 0;
}
next prev parent reply other threads:[~2009-03-27 20:51 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-27 20:24 [PATCH 0/3] Ext3 latency improvement patches Theodore Ts'o
2009-03-27 20:24 ` [PATCH 1/3] block_write_full_page: Use synchronous writes for WBC_SYNC_ALL writebacks Theodore Ts'o
2009-03-27 20:24 ` [PATCH 2/3] ext3: Use WRITE_SYNC for commits which are caused by fsync() Theodore Ts'o
2009-03-27 20:24 ` [PATCH 3/3] ext3: Avoid starting a transaction in writepage when not necessary Theodore Ts'o
2009-03-27 22:23 ` Jan Kara
2009-03-27 23:03 ` Theodore Tso
2009-03-30 13:22 ` Jan Kara
2009-03-27 22:20 ` [PATCH 2/3] ext3: Use WRITE_SYNC for commits which are caused by fsync() Jan Kara
2009-03-27 20:55 ` [PATCH 1/3] block_write_full_page: Use synchronous writes for WBC_SYNC_ALL writebacks Jan Kara
2009-04-07 6:21 ` Andrew Morton
2009-04-07 6:50 ` Andrew Morton
2009-04-07 7:08 ` Jens Axboe
2009-04-07 7:17 ` Jens Axboe
2009-04-07 8:16 ` Jens Axboe
2009-04-07 7:23 ` Andrew Morton
2009-04-07 7:57 ` Jens Axboe
2009-04-07 19:09 ` Theodore Tso
2009-04-07 19:32 ` Jens Axboe
2009-04-07 21:44 ` Theodore Tso
2009-04-07 22:19 ` [PATCH] block_write_full_page: switch synchronous writes to use WRITE_SYNC_PLUG Theodore Tso
2009-04-07 23:09 ` Andrew Morton
2009-04-07 23:46 ` Theodore Tso
2009-04-08 8:08 ` Jens Axboe
2009-04-08 22:34 ` Andrew Morton
2009-04-09 17:59 ` Jens Axboe
2009-04-08 6:00 ` Jens Axboe
2009-04-08 15:26 ` Theodore Tso
2009-04-08 5:58 ` [PATCH 1/3] block_write_full_page: Use synchronous writes for WBC_SYNC_ALL writebacks Jens Axboe
2009-04-08 15:25 ` Theodore Tso
2009-04-07 14:19 ` Theodore Tso
2009-03-27 20:50 ` Chris Mason [this message]
2009-03-27 21:03 ` [PATCH 0/3] Ext3 latency improvement patches Chris Mason
2009-03-27 21:19 ` Jan Kara
2009-03-27 21:30 ` Theodore Tso
2009-03-27 21:54 ` Jan Kara
2009-03-27 23:09 ` Theodore Tso
2009-03-28 0:14 ` Jeff Garzik
2009-03-28 0:24 ` David Rees
2009-03-30 14:16 ` Ric Wheeler
2009-03-30 11:23 ` Aneesh Kumar K.V
[not found] ` <20090330112330.GA11357@skywalker>
2009-03-30 11:44 ` Chris Mason
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=1238187031.27455.212.camel@think.oraclecorp.com \
--to=chris.mason@oracle.com \
--cc=jack@suse.cz \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rwheeler@redhat.com \
--cc=tytso@mit.edu \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).