Re: Why is fsync so much slower than O_SYNC?

From: Andrew Morton
Date: Thu Mar 18 2004 - 12:13:13 EST


Jeffrey Siegal <jbs@xxxxxxxxxxx> wrote:
>
> Andrew Morton wrote:
> > This is because ext3 is being dumb. It is forcing a journal commit even
> > when the inode has not been altered.
> >
> > Here's a moderately-tested 2.6 fix. A 2.4 fix would be similar.
> >
> >
> > File overwrite:
> >
> > vmm:/mnt/hda5> ~/fsync-is-sucky
> > O_SYNC:
> > Creating
> > Starting
> > iter = 1000, latency = 0.191464ms
> >
> > O_DSYNC:
> > Creating
> > Starting
> > iter = 1000, latency = 0.181637ms
> >
> > fsync:
> > Creating
> > Starting
> > iter = 1000, latency = 0.186326ms
> >
> > fdatasync:
> > Creating
> > Starting
> > iter = 1000, latency = 0.193013ms
>
> Hmm, this doesn't seem right. For an overwrite, it should still be
> waiting for just the data page to be written out, and that should take
> about 8ms (for a 7200rpm drive),

That's with the disk writeback cache enabled.

> and the append case should take longer,
> since it requires writing both the data page and then the journal.

Append takes 40 times longer, because in that case we need to commit the
journal after each sync to write the modifed inode.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/