public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jon Burgess <lkml@jburgess.uklinux.net>
To: linux kernel <linux-kernel@vger.kernel.org>
Subject: ext2/3 performance regression in 2.6 vs 2.4 for small interleaved writes
Date: Wed, 11 Feb 2004 19:04:00 +0000	[thread overview]
Message-ID: <402A7CA0.9040409@jburgess.uklinux.net> (raw)

[-- Attachment #1: Type: text/plain, Size: 1034 bytes --]

I wrote a small benchmark tool to simulate the pattern of writes which 
occur when slowly streaming files to disk.
This is trying to replicate the filesystem activity when I record 
multiple TV and radio channels to disk.

I have attached a copy of the test program. It measures how long it 
takes to write a number of files in parallel, writing a small amount of 
data to each file at a time. I noticed that results for ext2 on 2.6.2 
are much slower than 2.4.22:

Write speed in MB/s using an ext2 filesystem for 1 and 2 streams:
Num streams:     1      2
linux-2.4.22   10.47  6.98
linux-2.6.2     9.71  0.34

"vmstat" agrees with the performance figures. It seems that the pattern 
of small interleaved writes to two files really upsets something in the 
2.6 code. 

During the disk light is on solid and it really slows any other disk 
access. It looks like the disk is continuously seeking backwards and 
forwards, perhaps re-writing the meta data.

Does this look like a problem, or is the test unrealistic?

Thanks,
    Jon



[-- Attachment #2: trial.c --]
[-- Type: text/plain, Size: 1895 bytes --]

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/param.h>
#include <string.h>
#include <sys/time.h>

#define BSIZE  (4 * 1024)

#define MAX_NAME (256)
char base_name[MAX_NAME];

char *get_name(int n)
{
  static char name[MAX_NAME + 5];
  
  sprintf(name, "%s%d", base_name, n);
  return name;
}


void display_rate(struct timeval start, struct timeval end, int len) 
{
  int d_s, d_us;
  float sec;

  d_s  = end.tv_sec  - start.tv_sec;
  d_us = end.tv_usec - start.tv_usec;

  sec = d_s + d_us / 1000000.0;

  printf("Transferred %dMb of data in %.2f seconds (%.2fMb/s)\n",
	 len, sec, len / sec);
  fflush(NULL);
}

void create_files(int n, int sz)
{
  int out[n], i;
  char buf[BSIZE];
  int pos;
  struct timeval start, end;

  printf("Writing %dMb of data to %d files in parallel\n", sz, n);
  fflush(NULL);

  for (i = 0; i < n; i++) {
    out[i] = open(get_name(i), O_WRONLY | O_CREAT | O_TRUNC, 0666);
    if (out[i] < 0) {
      perror("Creating output file");
      exit(1);
    }
  }

  memset(buf, 0, BSIZE);
  
  gettimeofday(&start, NULL);

  for (pos = 0; pos < (sz * 1024 * 1024); pos += BSIZE) {
    for(i = 0; i < n; i++) {
      if (write(out[i], buf, BSIZE) != BSIZE) {
	  fprintf(stderr, "Problem writing output file\n");
	  exit(2);
      }
    }
  }
  
  for (i=0; i<n; i++) {
    fdatasync(out[i]);
    close(out[i]);
  }

  gettimeofday(&end, NULL);

  display_rate(start, end, n * pos / (1024 * 1024));
}


void delete_files(int n)
{
  int i;
  
  for (i = 0; i < n; i++) {
    unlink(get_name(i));
  }
}

void run_test(int n, int s)
{
  delete_files(n);

  create_files(n, s);

  delete_files(n);

  printf("\n");
  fflush(NULL);
}  

int main(int argc, char *argv[])
{
  unsigned int  s = 16;
  strcpy(base_name, "temp_");

  run_test(1, s);
  run_test(2, s / 2);

  return 0;
}

             reply	other threads:[~2004-02-11 19:04 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-02-11 19:04 Jon Burgess [this message]
2004-02-11 20:28 ` ext2/3 performance regression in 2.6 vs 2.4 for small interleaved writes Rik van Riel
2004-02-11 21:02   ` Michael Frank
2004-02-11 21:18     ` Diego Calleja
2004-02-12  2:00       ` Dave Olien
2004-02-12  2:23         ` Andrea Arcangeli
2004-02-12  9:42           ` ext2/3 performance regression in 2.6 vs 2.4 for small interl Giuliano Pochini
2004-02-12 10:15             ` John Bradford
2004-02-12 10:27             ` Nick Piggin
2004-02-12 17:05               ` Michael Frank
2004-02-12 17:18                 ` Valdis.Kletnieks
2004-02-12 20:55                   ` Helge Hafting
2004-02-13  1:57                     ` Jamie Lokier
2004-02-13  2:05                       ` Nick Piggin
2004-02-12 14:59             ` Andrea Arcangeli
2004-02-13 12:15     ` ext2/3 performance regression in 2.6 vs 2.4 for small interleaved writes Jon Burgess
2004-02-12 10:40   ` Jon Burgess
2004-02-12 20:17     ` Hans Reiser
2004-02-12  9:56 ` Andrew Morton
2004-02-12 20:20   ` Jon Burgess
2004-02-13  8:28     ` Juan Piernas Canovas
2004-02-16 17:51     ` Alex Zarochentsev
2004-02-16 20:03       ` Jon Burgess
2004-02-13 12:35   ` Jon Burgess
2004-02-14 15:00   ` Jon Burgess

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=402A7CA0.9040409@jburgess.uklinux.net \
    --to=lkml@jburgess.uklinux.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox