Swap space.

Posted:
in macOS edited January 2014
Sigh. I can't get a definitive answer anywhere...does changing your swap space to a dedicated partition make a speed difference in everyday use? If this was true in 10.1, is it still true in 10.2?



Opinions are welcome in place of hard facts, if that is all people have.

Comments

  • Reply 1 of 15
    No. The only cases that would make any noticeably difference are when the drive is near-full or heavily fragmented.



    Consider this: why would you think it should be faster? The system is still having to access the same drive at the same speed -- it's just that the files are in a different location.



    It AppleInsider's search was working, I'd dig up a great old thread where we explained this whole mess. <img src="graemlins/hmmm.gif" border="0" alt="[Hmmm]" /> Ah well.
  • Reply 2 of 15
    The only way you are going to speed it up is if you have a seperate physical drive for swap not a partition. Partitions are logical drives on one physical drive.
  • Reply 3 of 15
    airslufairsluf Posts: 1,861member
  • Reply 4 of 15
    mrmistermrmister Posts: 1,095member
    Thanks AirSluf for that--that does jive with what I expected, but there is an amazingly poor signal/noise ratio on this topic on the Net, and I wanted to get the skinny before I wasted time "trading spaces".
  • Reply 5 of 15
    serranoserrano Posts: 1,806member
    Thankyou Airsluf for giving a correct answer, and saving me the time.
  • Reply 6 of 15
    123123 Posts: 278member
    [quote]Originally posted by Brad:

    <strong>No. The only cases that would make any noticeably difference are when the drive is near-full or heavily fragmented.

    </strong><hr></blockquote>



    Depends on what you think is "noticeable". If you create a swap partition at the beginning of the drive, swapping will always be as fast as it can be. If you don't create a dedicated partition and your drive is half full, the performance won't be that good anymore, around 75-80%. If we are talking about some serious disk thrashing, this is noticeable.



    Edit:

    [quote]<strong>

    Consider this: why would you think it should be faster? The system is still having to access the same drive at the same speed -- it's just that the files are in a different location.</strong><hr></blockquote>

    That's exactly the point: it's just that the files are in a different location.



    [ 10-11-2002: Message edited by: 123 ]</p>
  • Reply 7 of 15
    mrmistermrmister Posts: 1,095member
    Here we go again.



    See, in OS 10.1.5 I did just that--I used my OS9 partition for my swap space, as it was a small (around 1 gig) partition right at the front of my total drive.



    The question is: is this a theoretical efficiency, or a measurable one?
  • Reply 8 of 15
    123123 Posts: 278member
    [quote]Originally posted by mrmister:

    <strong>

    The question is: is this a theoretical efficiency, or a measurable one?</strong><hr></blockquote>



    It's both, a theoretical efficiency and a measurable one, but in many cases probably not a noticeable one.



    The read/write speed of a hard disk depends on the position of your data on the disk (look here for example: <a href="http://www.tomshardware.com/storage/02q1/020305/images/wd1200jb-diagram.gif"; target="_blank">http://www.tomshardware.com/storage/02q1/020305/images/wd1200jb-diagram.gif ).</a> However, these are sequential speeds. Sometimes, only 4KB pages are read(/written) from the disk in a non-sequential manner. In this case, access time will be much longer than raw transfer time. Sometimes however, big chunks of memory are transfered and then a partition at the beginning of the drive will be (a little) faster.



    BUT:

    -If you have enough memory and swapping doesn't occur very often, setting up a dedicated partition is probably not worth the trouble.



    -If you don't have enough memory and thrashing occures on a regular basis, you should buy more RAM, because THIS IS noticeably faster than the fastest dedicated swap disk on a separate IDE controller.



    [ 10-12-2002: Message edited by: 123 ]</p>
  • Reply 9 of 15
    airslufairsluf Posts: 1,861member
  • Reply 10 of 15
    123123 Posts: 278member
    [quote]Originally posted by AirSluf:

    The data read time is statistically irrelevant over the life of the drive for small files, and swap reads are all small file reads as they are pulled as individual memory pages.<hr></blockquote>



    And this is wrong.



    Often a much larger request is made to the pager to increase performance. Not only the page that caused the page-fault but several other pages (that may be needed later) are swapped in at once.





    [quote]Originally posted by AirSluf:

    Statistically the best place to put a frequently read partition is across the center cylinders of the physical drive, then the long term average seek time will be at its shortest. Putting the partition at either periphery guarantees the maximum average long term read latency and utterly destroys any actual data throughput speed gains for those small files in a swap space.<hr></blockquote>



    "center cylinders"? I don't think so, I suppose you mean middle sectors.



    Well, your logic is not consistent anyway. First you disagree with BrianMacOS's statement that a seperate drive will be necessary to improve performance, then you base your argument on a situation where one would indeed set up a dedicated swap disk: You are assuming that between two page faults the disk is used for other purposes (and the heads will be moved to a random position across the whole disk). In this case a dedicated disk would be much faster because nobody would ever move the heads between swaps and thus seek time could be improved considerably. However, I think this scenario is far-fetched.



    Swaps occur in clusters. After the initial positioning, seek times are shorter at the beginning of the disk.



    Also, the position of the heads is definitely not uniformly distributed. Frequently read partitions/files should be grouped together. As far as access time is concerned, it doesn't really matter where you put them because the heads will have to leave these partitions only occasionally. If you put them at the beginning of the disk, you'll have the additional benefit of great sequential read/write speeds, so this is the preferred location.



    This means that if you create a system partition at the beginning (sequential speed matters) of the disk right next to your swap partition, the heads are very often already near their destination when a page-fault occurs. If you don't create such a partition, the OS (libraries, tools, utilities etc.) is also at the beginning of the disk (however, several additional libs etc. you've installed yourself are not).



    [ 10-12-2002: Message edited by: 123 ]</p>
  • Reply 11 of 15
    airslufairsluf Posts: 1,861member
  • Reply 12 of 15
    123123 Posts: 278member
    [quote]Originally posted by AirSluf:

    <strong>OK Mister smarty pants, spouting off without reading the basic documentation or proper knowledge of terminology completely wreks your credibility.</strong><hr></blockquote>





    Wow, you haven't changed a bit since our last little discussion (blocking finder/funnels).



    [quote]<strong>1) Sectors comprise a track on the physical surface of a drive. Several platters worth of aligned tracks make a cylinder. This is about the most basic of HD architecture concepts. Kids that listen in high school get this right.</strong><hr></blockquote>





    Wait...terminology... where did I say that I don't know cylinders? What you said is wrong, namely, that a frequently read partition should be created around "center cylinders" (given your scenario). Not "center", not "cylinders", also not "center cylinders" by itself is wrong, but "center cylinders" in your context is (it's about math, not terminology). Making the same assumptions YOU made, it's just a wrong statement. I suggested middle sectors becuase that would be about right.



    [quote]<strong>2) You seem to be confusing cache-RAM requests with virtual memory paging. It seems you haven't read this: Mach Kernel Principles, or anything else on Darwin memory management. There is some light reading through the Apple developer docs, but that doesn't get into the guts of the paging apparatus, just a bare touching overview.</strong><hr></blockquote>





    Hmm, let's see. Maybe someone did read the basic documentation but nothing that "get(s) into the guts of the paging apparatus"?

    <a href="http://developer.apple.com/techpubs/macosx/Darwin/General/KernelProgramming/vm/Working_Set_n_Subsystem.html"; target="_blank">http://developer.apple.com/techpubs/macosx/Darwin/General/KernelProgramming/vm/Working_Set_n_Subsystem.html</a>;



    However, when I was saying "Swaps occur in clusters.", my point was not that pages are read in bigger chunks (true, I shouldn't have used "clusters"), I was merely referring to the fact, that swaps don't occur uniformly distributed in time. For example, when a program needs a big amount of memory or when another program is activated after being idle for a long time, a lot of paging occurs (very short intervals between them). I wanted to point out that the position of your heads before such paging activity doesn't matter because you only have to move them once to the swap partition and then have many writes/reads/(seeks) without them being moved to another partition. Also as I said, seek times on the swap partition are shorter if the partition is at the beginning of the disk.



    [quote]<strong>No inconsistencies here. I merely showed how there could be a significant advantage (if you meet all the worst case requirements) even if don't have a second drive to put the swap partition on. If you spent time analyzing what you read before jumping to flawed conclusions you would have picked up on this.</strong><hr></blockquote>





    As your worst case requirements will hardly ever be met in the real world anyway (which you said so yourself), I assume you posted this little information for our amusement only, no inconsistencies here indeed, I appologize. My point was that if you really run a program that constantly (between individual swaps) writes or reads from random parts of your disk and at the same time needs huge amounts of memory, you better use a dedicated swap disk. I agree, that under these conditions and without a dedicated swap disk, a swap partition around the middle sectors would give you the best results. But then again, this is just one scenario out of many others and highly unlikely, a nice thought experiment... but nothing more.



    [quote]<strong>You do make a valid point that if the swap disk is ONLY used for the swap file you will get a significant advantage. How many installations do this? Probably a number closely approaching zero.</strong><hr></blockquote>



    Why does it have to be used as a swap drive only? Now your application is constantly accessing the second drive? Well, then create the swap partition on your sysem drive. Ah, the program is hammering both disks? Ok, then put it on a third drive.... or yes, create the partition aroud the middle sectors.





    [quote]<strong>In practice, a disk in use gains a stochastically driven file location distribution</strong><hr></blockquote>



    Stochastically driven distribution = uniform distribution?



    [quote]<strong>, especially with the recently written data you point out is most likely to be accessed soonest. Thus your recent read/writes drive the heads away from the blocked-in and carefully placed swap space at the head of the disk.</strong><hr></blockquote>



    That's why you create partitions in the first place. Swap files, libraries, utilities, preferences, temp files, development tools/environment, projects you're currently working on, applications etc. first (Swap partition/System partition/Development partition/Apps partition). Rarely accessed documents, Word letters, archived data, perl script repository, old OS9 stuff, code snippets, James Bond DiVX movie last. I am talking about the average case. You can always come up with something that will lead to very poor performance. However, if you create your partitions in an intelligent manner based on how you use your system, you can avoid most of these situations.



    [quote]<strong>Also what happens if you work with large files and need to expand the swap space? Then you shatter the whole set-up. Brittle solutions seldom result in long term performance gains.</strong><hr></blockquote>





    You can always change the location of your swap files if you suddenly need a huge amount of swap space. However, should I become a 3d video artist and need 10GB of swap space or whatever on a regular basis, you're right. Just that I don't think this will happen anytime soon...
  • Reply 13 of 15
    airslufairsluf Posts: 1,861member
  • Reply 14 of 15
    murbotmurbot Posts: 5,261member
    [quote]It AppleInsider's search was working, I'd dig up a great old thread where we explained this whole mess. <img src="graemlins/hmmm.gif" border="0" alt="[Hmmm]" /> Ah well.[/QB]<hr></blockquote>



    No worries Brad, it's being recreated for you.



  • Reply 15 of 15
    overhopeoverhope Posts: 1,123member
    But new, improved and with added bitching... <img src="graemlins/bugeye.gif" border="0" alt="[Skeptical]" />
Sign In or Register to comment.