1

On some of my Linux servers, the swap partition is misaligned. I understand how partition alignment affects performance on mounted file systems with 4k block sizes, but I am unsure if the same considerations apply to swap.

Does it even have a "block size" as such? Is there any performance benefit to aligning a swap partition one way or another?

2 Answers 2

1

Yes, swap partition alignment is important, but not very important.

Memory pages can be swapped only in whole. Considering that they can be 4k or 8k in most cases (depending on CPU architecture), you need to make sure that the partition has at least this kind of alignment.

With current disks it's best to align to 4MiB boundaries though. So you won't even need to know the size of your memory pages.

The system shouldn't swap under regular load, so swap alignment will have no visible difference, if it will have any effect at all.

2
  • All good, except for "The system shouldn't swap under regular load" -- while you shouldn't have a high swap rate, putting unused pages out to disk is a good thing, as it leaves more RAM for disk cache.
    – womble
    Mar 11, 2012 at 11:57
  • 1
    The system may dribble swap out under normal load a bit. But the system shouldn't swap enough for swap performance to make any difference at all. But there is a myth that literally no swapping should occur under normal load, and that's false for precisely the reason womble mentioned. Mar 11, 2012 at 14:04
0

One more thing is that if you only have moderate load and a caching raidcontroller then the controller will happily work out the alignment issues for you. I've run into that when benchmarking well- and misaligned partitions on raid10. There was no difference ever at all, because the controller had enough idle time to cover up for it.

So, as with answer #0, it depends on your swap in/out ratio and system load. If the system's idle, it will all be fine, while if it's always under memory pressure then you should think about fixing it since it can cut your swap performance in half.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .