Aligning file system data
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
How likely is it that I can actually align stuff to 31.5KiB on the physical disk, i.e. have each block be a track?
Rather than leveraging the track cache, would it be less expensive for me to simply read in blocks totaling about 16 or 32KiB all at once?
Let's say I have two situations...
A)
My blocks are all 31.5KiB (512 bytes/sector * 63 sectors) and aligned
to tracks. The track cache on the disk stores the entire block, so repeted reads to the disk are 0mS seek. I leverage this to read a couple sectors at a time and seek as I care within the block while it's cached, making several requests to the ATA device.
B)
My blocks are all 32KiB and cross track boundaries. All of them exist
in part in two separate tracks. Upon reading a block, I request the entire block and work with it in main memory.
Which situation has less overhead?
C)
My blocks are all 31.5KiB and perfectly aligned within tracks. I read
the entire block as in (B) and work with it in main memory.
How much more latency is involved in (B) than in (C)? Does crossing a track boundary incur anything expensive?
- --
All content of all messages exchanged herein are left in the Public Domain, unless otherwise explicitly stated.
Creative brains are a valuable, limited resource. They shouldn't be wasted on re-inventing the wheel when there are so many fascinating new problems waiting out there.
-- Eric Steven Raymond
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQFCSivPhDd4aOud5P8RAszeAJ4wPonhpXas8IprMBUq8/NdM57aegCdEBva 24LXB3O+7GEE0XKxPBFr1L0=
=iTEm
-----END PGP SIGNATURE-----
Quoted 2 lines · In article <[email protected]> you wrote:
How likely is it that I can actually align stuff to 31.5KiB on the physical disk, i.e. have each block be a track?
It is not that easy to allign on tracks, even on raw partition. Some disks have different length of tracks (of course because the inner cylinders are shorter), some show a totally different geometry than they have internally, and the disks are happyly remapping.
With raid and lvm the situation get worse.
Why do you want to do thoe micro optimizations?
With a filesystem in between you have virtuelly no way to allign larger files for streaming.
Let the buffer cache and prefetch do, what they are intended for and feel happy.
Greetings
Bernd
Quoted 2 lines · John Richard Moser
Does crossing a
track boundary incur anything expensive?
AFAIK, yes. It's going to involve some kind of seeking (even a head switch needs microjogging on modern drives), and it will certainly add latency (although I don't remember how much, off the top of my head).
However, trying to control this from the kernel may be vastly harder than you're expecting (assuming a modern hard drive). You may want to look at these pages for more info:
http://www.storagereview.com/guide2000/ref/hdd/geom/tracksZBR.html
http://www.storagereview.com/guide2000/ref/hdd/geom/geomLogical.html
Also look at the last paragraph on this page -- not the paragraph with the "Stop" sign, but the one after it:
http://www.storagereview.com/guide2000/ref/hdd/geom/formatDefect.html
I think this could in fact be done, but it would be a lot of effort, and the kernel would need knowledge on a per-drive-model basis (or at least it would need a way to obtain such knowledge from user space, and the per-model knowledge would need to be stored there somehow). For all I know, vendor-specific commands might also be needed in order to find out which blocks are remapped, in order to use that knowledge to avoid changing tracks spuriously. (And one other note: Since your device almost certainly has many tracks with well over 256 sectors in reality, your device is actually incapable of reading or writing a single track with a single ATA command unless it supports LBA48.)
-Barry K. Nathan <[email protected]>