Seperate swap file partition

Posted:
in macOS edited January 2014
I know this has been asked before, but I can't seem to search the forums: I am going to do a clean install of OS X on my hard drive, and I wanted to make a seperate partition for the swap file. How big should this be, and how do I put the swap file on it? (Sorry if this belongs in the genius bar, I wasn't sure where to put it)

Comments

  • Reply 1 of 19
    I can't give you instructions, but I can tell you that this has been debated and that there are virtually zero performance gains from moving the swap to another partition. The only reason I can think that someone would want to do this is if he or she is worried about simply running out of space on the startup partition of if the free space becomes heavily fragmented. For the vast majority of users neither of these is a real problem. I also advise extreme caution if you do decide to make the switch because incorrectly moving the swap can really mess up the system.
  • Reply 2 of 19
    123123 Posts: 278member
    [quote]Originally posted by Brad:

    <strong>I can't give you instructions, but I can tell you that this has been debated and that there are virtually zero performance gains from moving the swap to another partition.</strong><hr></blockquote>



    I can't find that thread anymore either, but I'm sure that I explained clearly why a seperate partition (or a seperate system partition) is faster in theory. How much depends on your particular file access patterns. I tend to agree that for most users the speedup is hardly noticeable (most of the time), but "virtually zero performance gains" is not always true.



    EDIT:

    Found it: <a href="http://forums.appleinsider.com/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=5&t=001576"; target="_blank">http://forums.appleinsider.com/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=5&t=001576</a>;



    As you can see, I just got tired in the end, but I think it's all there. (For those wondering about the cylinder-sector debate: the middle sectors are not on the central cylinders on modern hard drives (but at about 2/3), another thing that a certain ai member didn't seem to know...)



    [ 01-18-2003: Message edited by: 123 ]</p>
  • Reply 3 of 19
    airslufairsluf Posts: 1,861member
  • Reply 4 of 19
    123123 Posts: 278member
    [quote]Originally posted by AirSluf:

    YOU were the only person talking about those middle sectors and their locations!).<hr></blockquote>

    Yes. You were talking about "central cylinders" which made little sense because what is it? If a disk has m cylinders, the "central cylinders" are usually those around #m/2, this, however, is not where you want to create a swap partition in general. A more modern definition could help, but it would depend a lot on disk layout, in fact it would solely depend on the location of the middle sector (logical sector number n/2 on a disk with n sectors) which is why I was talking about those sectors.

    [quote]Either way, bad for credibility. No wonder you got tired...<hr></blockquote>

    Credibility? I like that, maybe you just re-read your statements regarding "the paging apparatus" before worrying too much about other people's credibility.

    [quote]That is 100% incorrect as sectors populate every track and cylinders are just vertically aligned collections of tracks.<hr></blockquote>

    Ok, this wasn't clear enough. With "2/3" I meant at/on cylinder number m*1/3 (numbering from the outside towards the inside, m=number of cylinders), exact numbers vary from product to product.

    [quote]It's more important to have enough RAM and plenty of free space on the drive/system-partition than getting particularly fancy with swap partitions.<hr></blockquote>

    I second that.



    [ 01-18-2003: Message edited by: 123 ]</p>
  • Reply 5 of 19
    spookyspooky Posts: 504member
    The Help docs for Maya 4.5 PLE state:



    By default, Mac OS X installs the virtual memory swapfile among the data files on your hard drive. If you open and quit programs frequently, or fragment your data files in other ways, Mac OS must search for the swapfile among pieces of data files. This can dramatically impact system performance.



    You can improve system performance by creating a separate partition for the swapfile. You'll notice an improvement throughout your OS X applications, including Maya. Because rendering in particular takes a great deal of memory, we highly recommend that you dedicate a partition to the virtual memory swapfile.



    You'll get the most performance improvement by creating a swapfile partition on a secondary drive, but you can use a partition on your existing boot volume if you have a single hard drive. This section describes how to create the partition on a separate drive, but the steps are nearly identical for either configuration.




    so what's going on ? does a swap file on a nw partition make any difference or not?
  • Reply 6 of 19
    airslufairsluf Posts: 1,861member
  • Reply 7 of 19
    airslufairsluf Posts: 1,861member
  • Reply 8 of 19
    123123 Posts: 278member
    [quote]Originally posted by AirSluf:

    <strong>

    quote:

    ------------------------------------------------------------------------

    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.

    ------------------------------------------------------------------------



    is still incorrect as it is not how Mach accesses the swapfile. And the response:





    quote:

    ------------------------------------------------------------------------

    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.

    ------------------------------------------------------------------------



    is a deft attempt at backpedaling</strong><hr></blockquote>



    No, because the second quote is not by any means connected to the first quote! I merely pointed out what I meant by "Swaps occur in clusters." (which was taken from somewhere else and has nothing to do with the first quote, a different argument) and that you didn't understand or address that point. What I said in the first quote is correct and I always said so. Backpedaling? In fact, I specifically told you to learn how darwin is doing paging (which you obviously still haven't). I wonder what's the point of this discussion, you don't know the basics and you also don't read my posts. Here we go again: <a href="http://developer.apple.com/techpubs/macosx/Darwin/General/KernelProgramming/vm/Working_Set_n_Subsystem.html"; target="_blank">OS X WS Subsystem</a> Which part of "To improve performance, Mac OS X has a subsystem known as the working set detection subsystem. This subsystem is called on a VM fault; it keeps a profile of the fault behavior of each task from the time of its inception. In addition, just before a page request, the fault code asks this subsystem which adjacent pages should be brought in, and then makes a single large request to the pager." and "Also, since it is based upon the application?s previous behavior, it tends to pull in pages that would probably have otherwise been needed later." don't you understand? Read the first quote again, then read your stupid answer and shut up.
  • Reply 9 of 19
    123123 Posts: 278member
    I think this has become a complete mess, so here are the 3 points on which we disagree:



    1) "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."



    2) Assuming (thought experiment) paging occurs uniformly distributed in time and the initial (radial) position of the heads is also uniformly distributed across all cylinders, if one wants to minimize access time (head movement), should the swap partition be put around the "central cylinder", which is "equidistant fron the inner and outer track", is this the mathematical optimum?



    3) In the real world, where paging is heavily "clustered in time" and often more than 4KB need to be read/written, where head movement between individual sectors must also be considered and the heads' position are not uniformly distributed across all cylinders (because of intelligent partitioning of your data more or less according to usage frequency), what would be the best (or at least a good) strategy?



    MY ANSWERS:

    1) This is correct (see last post), you've been proven wrong.



    2) No, this is not the mathematical optimum. It is in fact difficult to find this optimum (and depends on a particular disk layout) but it is definitely not around the center cylinders.



    First of all, let's talk about the "middle sector" again. I gave you a definition, so what's the problem? If you don't like that name, rename it to "car", "music", "sdiwedfg" or whatever you like better. In case you still don't understand what it is: read all sectors of the disk sequentially from the outside towards the inside, count these sectors. When you've read half of the sectors, you are there: the heads are at the cylinder containing the middle sector of the disk. This has nothing to do with physically addressing/accessing a sector or anything like that but with the middle of the data-stream of the physical disk.



    But on which cylinder is the middle sector? Here's a the mathematical (non-discrete) answer for a simplified disk with constant sector density across the disk:



    As you can see, if the inner cylinder has radius Ri and the outer cylinder has radius Ro, the middle sector is located at cylinder R with radius sqrt(Ro^2+Ri^2)/sqrt(2). This is obviously not ths same as (Ro+Ri)/2 (center cylinder).





    Now forget about the middle sector for a moment, let's find out, around what cylinder R we'd have to put a swap partition in our experiment to minimize the total overall access time. Here's the calculation (continuous, simplified disk):



    You don't need to be a genious to see that this is the very same cylinder as the one containing the middle sector. Again, this has ABSOLUTELY NOTHING TO DO WITH CENTER CYLINDERS. It has to be said that on real disks, sector density is not really constant but it's still "almost constant" thanks to ZBR. It doesn't change much but this is the reason why the best cylinder can't be determined without knowing the exact disk layout. I truly hope this was clear enough for you this time and you realize that you were wrong. Center cylinders (as by your definition) is an old concept for old disks that is now completely obsolete, you do know that it's already 2003, do you?





    3) Here we have to consider a few more things than in 2), especially that in real world situations several pages are read at the same (working set) time or in very short intervals (big transfer time but hardly any access time). For example, if you switch to another application, a lot of pages have to be read/written at once. Also don't forget the dynamic pager (split/merge). Quantitative analysis is impossible but some qualitative comparisons can still me made. Here's a list that compares a swap partition at the beginning of the disk and a swap partition somewhere in the middle of the disk:

    [code]

    Initial access time:

    - beginning: occasionally very long, mostly short (due to intelligent partitioning)

    + middle: occasionally long, mostly short (due to intelligent partitioning)

    (mostly equal, hardly ever different at all: worst case 10ms gain (full stroke 20ms))



    Access times during heavy paging activity (between individual page-ins/-outs):

    + beginning: mostly very short (because files are spread across less cylinders)

    - middle: mostly short (because files are spread across more cylinders)



    Transfer time of a single page:

    + beginning: very short

    - middle: very short



    Transfer time of a working set (see "OS X" paging) or many pages:

    + beginning: quite long

    - middle: very long

    (always a difference, e.g. 4MB of total transfer, beginning @ 40MB/s =&gt; 100ms, middle @ 30MB/s =&gt; 133ms, 33ms gain)



    Dynamic pager activities (movement):

    + beginning: shorter

    - middle: longer

    (always a big difference, big transfers, but doesn't occur very often)</pre><hr></blockquote>



    Although initial access time is shorter if you put the partition away from the beginning, this is only one factor and it's really not important for a user who has to wait several seconds for the beachball cursor to disappear after having switched to another app. In the case of severe paging (this is when it's annoying and optimization is important because paging is really noticeable, you don't have to optimize something you don't notice), initial access is a one time fee and doesn't dominate at all! Transfer time and access times between individual page-ins/-outs are much more important. So, again: put the swap partition at the beginning or create a not too big system partition at the beginning, then another partition for things you use frequently, e.g. apps, then one for things you use less frequently and so on. A second drive is even better and the best thing is to buy enough RAM.



    123



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

    Today you are correct, I'm not sure about your Kernel Programming reference in the October thread, because that was originally posted prior to the online doc update (Nov) and I obviously didn't pick up the same concepts and changes then. I don't know what exactly Apple had online then but it wasn't the same as it is today.



    See, I can be convinced and acknowledge it, <hr></blockquote>



    Well... I hope so. However, it needs very much to convince you. And even then "it wasn't the same as it is today". This documentation was exactly like this in october, look at the link in the original thread and you'll see that it is the same, the url itself includes the term "Working_Set_n_Subsystem" which wouldn't make any sense if it wasn't about the working set subsystem (which was introduced with Jaguar 10.2). My original comments wouldn't really make a lot of sense either, quote: Hmm, let's see. Maybe someone did read the basic documentation but nothing that "get(s) into the guts of the paging apparatus"? /quote. I can assure you that this was the same document and I also know that you know this.



    [quote]Originally posted by AirSluf:

    As for the specifics on hard disk hardware layout, I think you need to go back and look at it again, because that hasn't changed appreciably since the late 1970's. Density-yes, basics-no.<hr></blockquote>



    It's all about density. Old disks had a constant number of sectors per track. All modern hard disks use zone bit recording (ZBR). Look it up in google or look at this to get the picture: <a href="http://www.pcguide.com/ref/hdd/op/z_000995trackssectors.jpg"; target="_blank">http://www.pcguide.com/ref/hdd/op/z_000995trackssectors.jpg</a>; vs. this: <a href="http://www.pcguide.com/ref/hdd/geom/z_zbr.jpg"; target="_blank">http://www.pcguide.com/ref/hdd/geom/z_zbr.jpg</a>;
  • Reply 12 of 19
    123123 Posts: 278member
    [quote]Originally posted by AirSluf:

    <strong>Your assumptions are incorrect and the math is meaningless because it does not use correct assumptions. </strong><hr></blockquote>



    Are you for real? I CALCULATED THE OPTIMUM BASED ON ABSOLUTELY NO ASSUMPTIONS. IT DID TURN OUT THAT THE BEST CYLINDER IS THE ONE AT 1/sqrt(2)*sqrt(Ro^2 + Ri^2). To do the calculations I didn't use a) any definition of center cylinders and b) any other definition like middle sector or whatever. However: The best cylinder (minimal head movement) happens to be the same as the one containing the middle sector and not the center cylinder. This is pure coincidence (of course it hardly is, this is math after all) and has nothing to do with the calculations themselves. I actually assumed that you do understand some sort of basic calculus and therefore should be able to understand the calculations. It basically minimizes the sum of all areas of the disk (weight) multiplied by their distance from the (by definition best but unknown) cylinder R. If you want, you can divide c by (Ro^2*pi-Ri^2*pi) (the Area of the whole disk) and you get a probability dp instead of dA. In that case you sum up all distances from cylinder R multiplied by their relative probability and you'll get the expectation value E (that you should know after many years of attending statistic courses) which you then minimize. Because c divided by a constant is still a constant, everything stays the same, especially the result.
  • Reply 13 of 19
    airslufairsluf Posts: 1,861member
  • Reply 14 of 19
    123123 Posts: 278member
    quote:

    ------------------------------------------------------------------------

    As for #2. No. [...] the math is meaningless because it does not use correct assumptions. One of the particularly important assumptions you forgot to use was head repositions are 100x-1000x slower than rotational latency issues.

    ------------------------------------------------------------------------



    That's why I didn't consider rotational latency and transfer times in my proof at all. The whole thing is solely about head repositions. You hear that, it is a calculation that only minimizes head movement (as this is what we are talking about in #2) and absolutely nothing else. #3 is a different issue.





    quote:

    ------------------------------------------------------------------------

    The whole point of minimizing latency is about minimizing time. Without invoking the weighting of actual time[...]

    ------------------------------------------------------------------------



    Ok, so you don't like a linear approximation, fine. Come up with the exact actuator way-time dependency including the whole feedback control system and show me that R is now (Ro+Ri)/2 (=center cylinder). You are unbelievable!



    As math obviously isn't your forte, what about intuition? Let's assume the center cylinder would be the best cylinder. It's obvious that many more sectors are on the outer cylinders than are on the inner cylinders, right? I'm doing this now only for the two extreme cylinders, but you can apply the same thinking to every other cylinder pair with the same distance from the center cylinder:



    The heads have to go a long way (in fact (Ro-Ri)/2) if they were positioned on either one of the extreme cylinders to reach the center cylinder. Because there are a lot less sectors on the innermost cylinder than on the outermost cylinder, the heads are more likely to be on the outer cylinder than on the inner cylinder. Even though the heads are relatively likely to be on the outermost cylinder, you still let them travel a full (Ro-Ri)/2 just because of a much smaller possibility that the heads could also be on the innermost cylinder. It's obvious that if you shift the partition a little bit towards the outside, you'll reduce total cost (minimal probability * way increase &lt; higher probability * way gain). If you can't see this (and that therefore the center cylinder can't be the optimum), I can't help you.



    Edit: the way is of course (Ro-Ri)/2 (was (Ro+Ri)/2)



    [ 01-21-2003: Message edited by: 123 ]</p>
  • Reply 15 of 19
    murbotmurbot Posts: 5,261member




    [ 01-21-2003: Message edited by: murbot ]</p>
  • Reply 16 of 19
    airslufairsluf Posts: 1,861member
  • Reply 17 of 19
    airslufairsluf Posts: 1,861member
  • Reply 18 of 19
    123123 Posts: 278member
    [quote]Originally posted by AirSluf:

    <strong>Don't worry Murbot, I'm not interested in starting a flame war.



    I think never the twain shall meet and this one can pretty much finish here.



    Shall we let this dead horse rest 123?</strong><hr></blockquote>



    Look, the thing is that you don't even try to think. If you would do that, if you just asked yourself how to mathematically find the best cylinder, you'd soon find out what this is all about, since you don't want to do it (or can't), since you don't want to think through my arguments (or just don't understand them), it's really the best thing to finish here. What I don't like about this situation is that although you never tried to really understand my points and instead just ignored them, in the future you will continue to post wrong statements and I can do nothing about it because you just don't want to listen. I think I could convince you in an irc session or something where you would have to follow my arguments, but I agree that it can't be done on these boards.



    Of course, several things you posted in your last few posts are wrong again and would need to be discussed. It is however impossible to discuss anything with you unless one can show you a very easy to understand and obvious proof like a url where an authority speaks. Proofs which require some logical thinking of your own are a waste of time.



    Here's just one last thing (you are so obviously wrong again that I have to say something). Maybe other members on these boards will also come to the conclusion that nothing you say can be trusted and that your arguments base on nothing.



    "Yes outer tracks will be mildly faster, but not by the large percentages you show. The small percentage differences yield worst case differences on the order of 10's of microseconds, not 10's of milliseconds. That is still well below the threshold to make appreciable differences depending on what track you start at. "



    I have already posted an image back in the old thread and here it is again:

    <a href="http://www6.tomshardware.com/storage/20020305/images/wd1200jb-diagram.gif"; target="_blank">http://www6.tomshardware.com/storage/20020305/images/wd1200jb-diagram.gif</a>;

    This is just one example drive and I only post it because I happen to own one of these. You'll get a similar picture for all other drives. Outer tracks are not "mildly faster, but not by the large percentages you show", they are MUCH faster and the percentage I was talking about is more or less what you get from the picture if you consider both read and write.
  • Reply 19 of 19
    airslufairsluf Posts: 1,861member
Sign In or Register to comment.