Why are disk writes so slow?

Mark Bucciarelli mark at gaiahost.coop
Tue Sep 26 11:05:40 PDT 2006


On Tue, Sep 26, 2006 at 01:03:00PM -0400, Bill Moran wrote:
> In response to Mark Bucciarelli <mark at gaiahost.coop>:
> 
> > Can someone explain to me why writing is five times as slow as
> > writing?  What's going on in the computer?  
> 
> I'm rather confused as to exactly what your question is ...
> 

Heh, I'm just trying to understand how my computer works.  I was
surprised that writes were _so much_ slower than reads.  I
figured somebody here knew.

> First off, writes are slower than reads if the data you're
> reading is already cached in RAM.  Unless you have _very_
> little RAM in your machine, then anything that takes .023s to
> write is going to be able to fit entirely in the buffer cache,
> thus repeated access doesn't require any real disk activity.

I could try running the test immediately after rebooting.

Although I have no idea if he did.  I bet he didn't.  And we both
used the same size file: 1.5M.  I wonder how much RAM he had.

> Secondly, as to why Stevens saw less of a slowdown with O_SYNC
> than you did -- I doubt there's one easy answer.  Discs are
> manufactured differently now than they were in 93, and there's
> even a huge difference between different brands and different
> types (i.e. SCSI/SATA) in addition to the differences in
> hardware connecting the disks, and the drivers for that
> hardware.  There are dozens of places where the difference
> could be occurring.  I would guess that the drive itself does
> write caching, and this heavily optimizes async writes, but
> can't improve the performance of sync writes any.

I see.

Yeah, if you look at normal write compared to read speed that did
improve between the two data points.  So that supports your
conjecture.

So you think this data has no value?

                     1993       2006
                    -----       ----
(1) /dev/null write  0.3s       .005s  <-- read speed
(2) normal write     2.3s       .023s
(3) O_SYNC          13.4s       .364s

    (2) / (1)        7.6         4.6    1.5x faster

    (3) / (2)        5.8        15.8    2.75x slower relative to ASYNC

    (3) / (1)       44.6        72.8    1.5x slower relative to read


It does makes me wonder how this test runs on Linux, since I
think databases use O_SYNC.  I guess I'd have to install Linux on
my laptop and run the same test to have any useful information.
And reboot between each test.  And shut down network interface
and all daemons.

In any case, thanks for your reply.

m


More information about the freebsd-performance mailing list