Interleaving swap and filesystem to reduce seek times

Oskar Pearson (oskar@is.co.za)
Thu, 7 Jan 1999 11:16:02 +0200


Hi All

I have a PC at home with 4Mb of ram. To say that it compiles slowly is an
understatement (it's been compiling the kernel for more than 24 hours now :)

When I originally installed Linux, I placed my swap at the beginning of the
disk, leaving the rest to data.

Since the machine has so little ram the cpu is 98% idle, it simply waits for the
disk heads to seek from one end of the disk (where the swap is) to the
middle of the disks (where the data is). Listening to this 'seek, seek,
seek' ad nauseum, it occurred to me that if I had put the swap in the middle
of the disk, average seek time would have been less.

I think it's possible to generalise this, though. (And I am sure that I am
not the first to think about this.)

Modern filesystems spread their inodes around the disk: only very old ones
kept their inode lists right at the beginning of the disk.

If we were to interleave the swap and filesystem, the seek time would (for
machines with one disk, at least) be reduced.

The kernel could also decide which section of swap to write to based on the
current position of the disk heads: if the heads seek back and forth
between the gcc compiler binary (to page the original binary back into
memory) and the source code, an intermediate block of swap could be used.
Disk head movements would then be limited to a fairly small section of
disk.

Has anyone seen any references to this? Has it been tried and discarded?

I guess that we could even use the 'bad blocks list' in ext2 to make space
for the many small swap areas, though that feels pretty kludgey.

Sure, the usefulness of this on multi-disk systems may be limited. I don't
believe (though I haven't looked at the swap code/memory subsystem at all)
that the swap system takes the current position of the heads into account.

Oskar

---
"Haven't slept at all. I don't see why people insist on sleeping. You feel
so much better if you don't. And how can anyone want to lose a minute -
a single minute of being alive?"				-- Think Twice

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