# [solved] Slow buffered disk reads

## mntnoe

I was unhappy with the performance on my laptop (Acer Travelmate 233XV with 30GB Ultra ATA/100), so I compared the disk i/o with my desktop:

hdparm -tT /dev/hda on desktop:

```
/dev/hda:

 Timing cached reads:   1056 MB in  2.00 seconds = 527.87 MB/sec

 Timing buffered disk reads:  158 MB in  3.03 seconds =  52.21 MB/sec
```

hdparm -tT /dev/hda on laptop:

```
/dev/hda:

 Timing cached reads:   1296 MB in  2.00 seconds = 647.47 MB/sec

 Timing buffered disk reads:   68 MB in  3.07 seconds =  22.12 MB/sec
```

Why is the buffered disk reads so slow on my laptop, and is it possible to fix?

I don't want to risk corrupting my data, so I am not keen messing with the options from an end. Thanks in advance.

```
hdparm /dev/hda:

 multcount    = 16 (on)

 IO_support   =  0 (default 16-bit)

 unmaskirq    =  0 (off)

 using_dma    =  1 (on)

 keepsettings =  0 (off)

 readonly     =  0 (off)

 readahead    = 256 (on)

 geometry     = 16383/255/63, sectors = 58605120, start = 0

hdparm -i /dev/hda:

 Model=IC25N030ATMR04-0, FwRev=MOAOAD0A, SerialNo=MRG211K2G3JHWD

 Config={ HardSect NotMFM HdSw>15uSec Fixed DTR>10Mbs }

 RawCHS=16383/16/63, TrkSize=0, SectSize=0, ECCbytes=4

 BuffType=DualPortCache, BuffSize=1740kB, MaxMultSect=16, MultSect=16

 CurCHS=16383/16/63, CurSects=16514064, LBA=yes, LBAsects=58605120

 IORDY=on/off, tPIO={min:240,w/IORDY:120}, tDMA={min:120,rec:120}

 PIO modes:  pio0 pio1 pio2 pio3 pio4 

 DMA modes:  mdma0 mdma1 mdma2 

 UDMA modes: udma0 udma1 udma2 udma3 udma4 *udma5 

 AdvancedPM=yes: mode=0x80 (128) WriteCache=enabled

 Drive conforms to: ATA/ATAPI-6 T13 1410D revision 3a:  ATA/ATAPI-2 ATA/ATAPI-3 ATA/ATAPI-4 ATA/ATAPI-5 ATA/ATAPI-6

 * signifies the current active mode
```

Last edited by mntnoe on Tue Jun 05, 2007 1:00 pm; edited 1 time in total

----------

## PaulBredbury

First check that you have sys-apps/hdparm-6.9-r1, to avoid a bug in reporting the speeds.

Use the search button for "hdparm", there's several threads here about optimizing performance.

I'd expect a laptop's hard drive to be slower than a desktop, because they are probably optimized for power consumption, heat and noise, rather than speed.

----------

## mntnoe

Thanks for answering, PaulBredbury. I upgraded to 6.9-r1, and now the cached read speed is reported half as big, so I must have been using the buggy version.

```
/dev/hda:

 Timing cached reads:   700 MB in  2.00 seconds = 349.35 MB/sec

 Timing buffered disk reads:   74 MB in  3.00 seconds =  24.66 MB/sec
```

On my laptop however, Windows copies a file with the same size faster than Linux, so I think there must be something that can be optimized.  So, if anybody could point out a weakness in my config, I would really appreciate that.

Generally, the discussions I have read about it doesn't cover when to enable the various options. The best I could find was http://gentoo-wiki.com/HOWTO_Use_hdparm_to_improve_IDE_device_performance, which explains some of the options. But what is read-lookahead, for example, and could I enable it on my laptop, without fear of corruption?

I tried to enable unmaskirq, but could not measure any differences; perhaps because it only helps when the system is busy. Any way to benchmark that?

----------

## PaulBredbury

That's too anecdotal. Give details about the file copy, and don't be fooled by disk caching.

There are some tweaks possible in /etc/fstab, e.g. I use:

```
/dev/sda1 / ext3  defaults,commit=60,noatime   1 1
```

Read man mount for details.

Edit: Added nodiratime

Edit2: Removed nodiratime, which is implied by noatimeLast edited by PaulBredbury on Tue Mar 15, 2011 12:52 pm; edited 2 times in total

----------

## eccerr0r

Laptop hard drives tend to be quite slow as said.

Of the four laptop drives I got, the last known reading I've seen:

Travelstar 40GN (20GB) 4200RPM: 20.3 MB/sec

Travelstar 40GNX (40GB) 5400RPM: 22.8 MB/sec

Fujitsu 30GB 4200RPM: 23.6MB/sec

Samsung 120GB 5400RPM: 31.5MB/sec

Don't take these as gospel, they're different versions of hdparm and some of these disks are very old (specifically, the Travelstars).

Likely you're not going to get much more out of them unless it's a newer 7200+RPM disk.

----------

## mntnoe

 *mntnoe wrote:*   

> On my laptop however, Windows copies a file with the same size faster than Linux, so I think there must be something that can be optimized.

 

Well, I was wrong...   :Embarassed: 

I ran a benchmark test from Windows, which reported 22.1 MB/sec avg, so yes, I might have been tricked by the cache/filesystem. Guess I'll have to live with that speed. 

Does commit=60 option actually improve the sync timing, or does it only give an illusion of fast copying with small files?

BTW on a laptop with a slow disk, should I then consider using "-Os" in my CFLAGS for large applications?

----------

## PaulBredbury

commit=60 stops the "immediate" (default of 5 seconds) prioritization of writes of over reads, caching the writes for a few more seconds later. This is good in the situation of heavy reads and writes mixed together, where the user wants the reads to take priority, so that the processor can be kept busy rather than pause while waiting for the writes to finish before it can continue reading.

A real-world example I have seen is waiting several seconds for the Gnome pull-down menu to appear, for seemingly no reason. The reason was that the disk was busy writing, so the CPU had to wait for the writing to finish before it could get all the data from the disk to be able to show the menu.

Hope that makes some sense  :Smile: 

----------

## mntnoe

Yes, I understand your point. I have added it to my fstab, so lets hope that I can feel a difference.

Thank you for your time...   :Smile: 

----------

## eccerr0r

On my machines that I care about disk space a lot I do use -Os (specifically, CF disks).  However I've found in practice it doesn't really help too much loading, burst speed reads are only a fraction of total time to satisfy requests (hint: seek times)

Sometimes I also wonder if you may just need more RAM in your machine?  Is it swapping?

I'm always worried about laptops with delayed writebacks because they're more susceptible to sudden power outages (battery runs out, etc.)  Either way, more RAM may help.

----------

## mntnoe

 *eccerr0r wrote:*   

> On my machines that I care about disk space a lot I do use -Os (specifically, CF disks).  However I've found in practice it doesn't really help too much loading, burst speed reads are only a fraction of total time to satisfy requests (hint: seek times)
> 
> Sometimes I also wonder if you may just need more RAM in your machine?  Is it swapping?
> 
> I'm always worried about laptops with delayed writebacks because they're more susceptible to sudden power outages (battery runs out, etc.) Either way, more RAM may help.

 

I started a thread about -Os. I will try it out, so I can compare load time vs. responsiveness.

I only have 256M, and although it isn't swapping, I ought to buy some more... when I can afford it   :Smile: 

I have set commit=15 so far. 15 seconds of "data loss" should be manageable, right?

----------

## eccerr0r

I probably shouldn't be as paranoid I guess.  With a journalling filesystem it shouldn't be nearly as big of a problem.

Depends on how much writing you're doing to the disk with "current" data (versus just copying data).

I hate data loss of any kind!  :Sad: 

----------

## mntnoe

Tried out firefox with -Os, but unfortunately it didn't help. 

See the thread linked above.

----------

## warrawarra

Mine works very nicely with 

-march=prescott -msse3 -m32 -pipe -O2

and

-j3 -s or -j16 -s 

-j3 = bottleneck and lag , -j16 very smooth and 3 compiles at the same time on core duo 2.16ghz t2600 .

Also parallel fetch.

But gcc 4.12 or gcc 4.2 takes forever on any config / machine.

----------

## sonicbhoc

what does -s in makeopts do?

----------

## LinuxSmiley

 *sonicbhoc wrote:*   

> what does -s in makeopts do?

 

man make

 *Quote:*   

>        -s, --silent, --quiet
> 
>             Silent operation; do not print the commands as they are executed.

 

----------

