Hi,

Le Sat, 8 Sep 2007 18:51:44 +0100,
"Ioannis Koltsidas" <[EMAIL PROTECTED]> a écrit :

> a) Does the value of /sys/block/sda/queue/read_ahead_kb (typically
> 128k) decide the amount of data that every read() fetches from the
> disk ?

Not for every read() : for uncached read()s only. E.g, if you read() 4
Kb from a disk, through the cache, it will in fact read 128 kb from the
disk to the cache, and then return the 4 kb to your application. When
you'll request the next 4 kb, they'll already be in cache.

The read-ahead functionality improves performances for sequential
read() operations. For random reads, read-ahead has no effect, or can
even degrade performances.

> b) hdparm specifies that parameter -m specifies the sector count for
> the Multiple Sector mode (aka IDE Block mode), which "permits the
> transfer of multiple sectors per I/O interrupt, rather than the usual
> one sector per interrupt". Are these multiple sectors consecutive
> (physically) or not? Because I can't see any benefit if they are not
> consecutive. And if they are indeed consecutive, isn't it the same
> thing with read_ahead_kb ?

No. The multiple sector mode allows the disk driver to request for more
than one sector at once. For example, to read 4 kb, without multiple
sector mode, the disk driver would have to send 8 requests to the disk
controller. Using multiple sector mode, it can simply ask for 8 sectors
at once (4 kb).

I would say that on current disks, multiple sector mode is always
available.

> I disabled the read_ahead feature (hdparm -A0 /dev/sda). Then I
> repeated the above and got:

You are making a confusion between software read-ahead and hardware
look-ahead. Software read-ahead is done by the linux kernel, and can be
configured using /sys/block/sda/queue/read_ahead_kb. Hardware
look-ahead is configured using hdparm's -A option.

For more information about hardware look-ahead, here is an excerpt from
[1] :

«
Read Look Ahead Feature
-----------------------
The Read Look Ahead feature improves performance by reading sectors
into a buffer before the sectors are actually requested by the host.
Assuming the disc is formatted for a 1:1 interleave, a series of
sequential reads of small blocks of data, rather than a single large
block, can cause a performance loss of up to one revolution per
command. The performance loss occurs when the controller is busy
sending the next Read command to the drive. During this interval, the
next sectors to be read can spin past the head. If this occurs,
reading the logical sector after the previously read sector requires
an extra revolution of the disc.
The Read Look Ahead feature improves performance by reading the
logical sector after the previously read sector into a buffer for
possible later use.
»

Sincerly,

Thomas

[1]
http://stason.org/TULARC/pc/hard-drives-hdd/seagate/ST1201A-SWIFT-178MB-3-5-HH-IDE-AT.html
-- 
PETAZZONI Thomas - [EMAIL PROTECTED] 
http://{thomas,sos,kos}.enix.org - Jabber: [EMAIL PROTECTED]
http://{agenda,livret}dulibre.org - http://www.toulibre.org
Fingerprint : 0BE1 4CF3 CEA4 AC9D CC6E  1624 F653 CB30 98D3 F7A7

Attachment: signature.asc
Description: PGP signature

Reply via email to