Re: swap partition leads to instability?
On Wed, 29 May 2013 19:52:02 + (UTC) jb wrote: RW rwmaillists at googlemail.com writes: BTW you mean paging, or swap use, rather that swapping. Linux supports only paging, so it can be taken as read that swapping means paging, but FreeBSD supports both. Yes, there is some confusion about the diff, if any, between paging and swapping. Paging - copying or moving pages between physical memory (RAM) and secondary storage (e.g. hard disk), in both directions. Swapping - nowdays is synonymous with paging. But its history is as follows (per Wikipedia): This is a bit Linux-centric. You say that FB supports both, Linux supports paging only. Well, Linux utilizes swap space as part of virtual memory. So, can you elaborate more on that - what is the essence of the diff, why should I avoid the term swapping when referring to Linux, assuming VMM systems on both ? You page-out pages and swap-out processes. When FreeBSD is very short of memory it swaps-out entire processes to concentrate the memory in the running processes. Linux goes directly from paging to killing processes. You can also set vm.swap_idle_enabled to allow idle processes to be swapped during normal use. This may help if a server has a lot memory tied up in processes that tend to be idle for long periods of time - traditionally used on shell servers. These days you'd probably want to be adding more memory. ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: swap partition leads to instability?
RW rwmaillists at googlemail.com writes: ... Yes, there is some confusion about the diff, if any, between paging and swapping. Paging - copying or moving pages between physical memory (RAM) and secondary storage (e.g. hard disk), in both directions. Swapping - nowdays is synonymous with paging. But its history is as follows (per Wikipedia): This is a bit Linux-centric. ... You page-out pages and swap-out processes. When FreeBSD is very short of memory it swaps-out entire processes to concentrate the memory in the running processes. Linux goes directly from paging to killing processes. That was helpful - knowing the details of VMM implementation in various OSs helps understand the generalizations, with exceptions ... jb ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: swap partition leads to instability?
RW rwmaillists at googlemail.com writes: On Sun, 26 May 2013 12:36:42 + (UTC) jb wrote: But, swapping is also a symptom, not a problem. It is never a good idea to let it get to that point. No, there are thing that are better on disk than in memory. The most common example is tmpfs. It's much better that files left on tmpfs can sent to disk rather tying up physical memory indefinitely. Yup, tmpfs - in virtual memory. That's an unfortunate excuse. But before its content are swapped out, the critical system like a server will be destabilized and show lame performance. The tmp-on-tmpfs has so many disadvantages that it is difficult to count and follow all of them. jb ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: swap partition leads to instability?
On Sun, 26 May 2013 18:48:18 -0500 Adam Vande More wrote: Um, that is wrong. It is in fact the basically the point of TRIM. And SSD's typically use the best form of wear leveling and it's usually advisable to leave a bit of the drive unpartitioned/unused to ensure the wear leveling works optimally. Would the UFS default 8% reserve achieve that? ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: swap partition leads to instability?
Fred Morcos fred.morcos at gmail.com writes: .. The improvement effect can be noticed on large inputs. These algorithms will most probably perform quite badly on small inputs. I think your concern has been addressed in review of various algos where base case identification helped to avoid overhead cost in small problem sizes relative to cache. http://erikdemaine.org/papers/BRICS2002/paper.pdf In light of available but not implemented better VMM algos, perhaps *BSD and Linux could eliminate or reduce the need for: - swap space - swapping out RAM even if there is no lack of it - overcommitment of memory (a bluff asking to be punished by OOM killer) - OOM killer Besides, they allow sloppy/dangerous programming. jb ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: swap partition leads to instability?
On Wed, May 29, 2013 at 1:19 PM, jb jb.1234a...@gmail.com wrote: Fred Morcos fred.morcos at gmail.com writes: .. The improvement effect can be noticed on large inputs. These algorithms will most probably perform quite badly on small inputs. I think your concern has been addressed in review of various algos where base case identification helped to avoid overhead cost in small problem sizes relative to cache. http://erikdemaine.org/papers/BRICS2002/paper.pdf I will check the paper out after work, but for clarification: Also, properly written cache-oblivious algorithms tend to recursively decompose the problem until it is small enough to fit in a cache and solve each part iteratively. -- refers to the base case. The issue is when the input is small enough to be solved faster iteratively but too large to fit in the cache. Also note that this is extremely machine and cache-dependent. Still, I will check the paper out :) thanks. In light of available but not implemented better VMM algos, perhaps *BSD and Linux could eliminate or reduce the need for: - swap space I run Archlinux without any swap space on a workstation laptop without problems. I occasionally fallocate a swapfile when I need to build GHC (usually in /tmp to make use of tmpfs). - swapping out RAM even if there is no lack of it Linux has a sysctl variable vm.swappiness which you can set to 0 or 1 out of 100. Not sure how to achieve the same on FreeBSD, maybe one or more combinations of the following? vm.swap_idle_threshold2: 10 vm.swap_idle_threshold1: 2 vm.stats.vm.v_swappgsout: 236969 vm.stats.vm.v_swappgsin: 28411 vm.stats.vm.v_swapout: 92607 vm.stats.vm.v_swapin: 28285 vm.disable_swapspace_pageouts: 0 vm.defer_swapspace_pageouts: 0 vm.swap_idle_enabled: 0 - overcommitment of memory (a bluff asking to be punished by OOM killer) - OOM killer Besides, they allow sloppy/dangerous programming. jb ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: swap partition leads to instability?
On Sun, 26 May 2013 12:36:42 + (UTC) jb wrote: But, swapping is also a symptom, not a problem. It is never a good idea to let it get to that point. No, there are thing that are better on disk than in memory. The most common example is tmpfs. It's much better that files left on tmpfs can sent to disk rather tying up physical memory indefinitely. BTW you mean paging, or swap use, rather that swapping. Linux supports only paging, so it can be taken as read that swapping means paging, but FreeBSD supports both. ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: swap partition leads to instability?
On Wed, 29 May 2013 13:57:22 +0200 Fred Morcos wrote: Linux has a sysctl variable vm.swappiness which you can set to 0 or 1 out of 100. Not sure how to achieve the same on FreeBSD, maybe one or more combinations of the following? You'll probably make things worse. vm.stats.vm.v_swappgsout: 236969 vm.stats.vm.v_swappgsin: 28411 vm.stats.vm.v_swapout: 92607 vm.stats.vm.v_swapin: 28285 These are just information vm.disable_swapspace_pageouts: 0 I'm not entirely sure, but I think this just disables paging at runtime - rather than compile time. vm.defer_swapspace_pageouts: 0 IIRC this defers paging, but it can end up with the paging done on the critical path rather in the background - it's usually a bad idea. vm.swap_idle_enabled: 0 vm.swap_idle_threshold2: 10 vm.swap_idle_threshold1: 2 This why you shouldn't confuse swapping and paging. These are about actually swapping-out processes. It's mainly about reducing memory use on multiuser systems where there many terminal idle at at any time. ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: swap partition leads to instability?
On Wed, May 29, 2013 at 6:19 AM, jb jb.1234a...@gmail.com wrote: - overcommitment of memory (a bluff asking to be punished by OOM killer) No self respecting Unix has an OOM by default. - OOM killer Are you suggesting FreeBSD does this crap? Besides, they allow sloppy/dangerous programming. Yup, in the kernel. -- Adam Vande More ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: swap partition leads to instability?
On Sun, May 26, 2013 at 6:17 PM, Adam Vande More amvandem...@gmail.comwrote: Normal dynamic wear leveling on a modern SSD will be better than imposing an FS- backed swap for 4GB partion occupying a small fraction of total drive space. Quite so. - M ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: swap partition leads to instability?
On Wed, 29 May 2013, Michael Sierchio wrote: On Sun, May 26, 2013 at 6:17 PM, Adam Vande More amvandem...@gmail.com wrote: Normal dynamic wear leveling on a modern SSD will be better than imposing an FS- backed swap for 4GB partion occupying a small fraction of total drive space. And you don't think the presence of TRIM--where the SSD can actually know which blocks are no longer in use--is worthwhile? ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: swap partition leads to instability?
On Wed, May 29, 2013 at 1:05 PM, Warren Block wbl...@wonkity.com wrote: And you don't think the presence of TRIM--where the SSD can actually know which blocks are no longer in use--is worthwhile? As a whole, TRIM is worthwhile. However when an SSD is overprovisioned it provides a lot of benefits. TRIM-less swap in this case doesn't. The PE rate of the worst MLC SSD's at this point is @3000 AFAIK. Given those figures and average desktop swap rate at my estimation, prioritizing write endurance on an SSD is not beneficial(especially with a SanForce). If you are swapping continuously something like ZeusRAM may be required. There are probably other solutions available as well as other 3rd party ones. If you are swapping a lot, the best case is usually to add RAM. -- Adam Vande More ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: swap partition leads to instability?
PS -- Moderating questions@ is just awful. I'm disappointed. On Wed, May 29, 2013 at 1:34 PM, Adam Vande More amvandem...@gmail.com wrote: On Wed, May 29, 2013 at 1:05 PM, Warren Block wbl...@wonkity.com wrote: And you don't think the presence of TRIM--where the SSD can actually know which blocks are no longer in use--is worthwhile? As a whole, TRIM is worthwhile. However when an SSD is overprovisioned it provides a lot of benefits. TRIM-less swap in this case doesn't. The PE rate of the worst MLC SSD's at this point is @3000 AFAIK. Given those figures and average desktop swap rate at my estimation, prioritizing write endurance on an SSD is not beneficial(especially with a SanForce). If you are swapping continuously something like ZeusRAM may be required. There are probably other solutions available as well as other 3rd party ones. If you are swapping a lot, the best case is usually to add RAM. -- Adam Vande More -- Adam Vande More ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: swap partition leads to instability?
RW rwmaillists at googlemail.com writes: On Sun, 26 May 2013 12:36:42 + (UTC) jb wrote: But, swapping is also a symptom, not a problem. It is never a good idea to let it get to that point. No, there are thing that are better on disk than in memory. The most common example is tmpfs. It's much better that files left on tmpfs can sent to disk rather tying up physical memory indefinitely. BTW you mean paging, or swap use, rather that swapping. Linux supports only paging, so it can be taken as read that swapping means paging, but FreeBSD supports both. Yes, there is some confusion about the diff, if any, between paging and swapping. Paging - copying or moving pages between physical memory (RAM) and secondary storage (e.g. hard disk), in both directions. Swapping - nowdays is synonymous with paging. But its history is as follows (per Wikipedia): Historically, swapping referred to moving from/to secondary storage a whole program at a time, in a scheme known as roll-in/roll-out. In the 1960s, after the concept of virtual memory was introduced — in two variants, either using segments or pages — the term swapping was applied to moving, respectively, either segments or pages, between memory and disk. Today with the virtual memory mostly based on pages, not segments, swapping became a fairly close synonym of paging. You say that FB supports both, Linux supports paging only. Well, Linux utilizes swap space as part of virtual memory. So, can you elaborate more on that - what is the essence of the diff, why should I avoid the term swapping when referring to Linux, assuming VMM systems on both ? jb ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: swap partition leads to instability?
On Wed, May 29, 2013 at 2:52 PM, jb jb.1234a...@gmail.com wrote: Well, Linux utilizes swap space as part of virtual memory. As does every other Unix. -- Adam Vande More ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: swap partition leads to instability?
On May 29, 2013, at 3:52 PM, jb jb.1234a...@gmail.com wrote: Yes, there is some confusion about the diff, if any, between paging and swapping. Paging - copying or moving pages between physical memory (RAM) and secondary storage (e.g. hard disk), in both directions. Swapping - nowdays is synonymous with paging. You say that FB supports both, Linux supports paging only. Well, Linux utilizes swap space as part of virtual memory. So, can you elaborate more on that - what is the essence of the diff, why should I avoid the term swapping when referring to Linux, assuming VMM systems on both ? When I started working professionally with Unix systems in 1995, I was taught that paging was the process of copying least used pages of RAM onto disk so that the RAM could be freed if the system needed more RAM. Swapping was the process of moving an entire program from RAM to disk in order to free up RAM. In other words, a process can be swapped out and placed on disk until it comes up to run again, at which point it can be swapped in and executed. I think that much of the confusion comes from the use of the SWAP device by the PAGING system. When the concept of paging came about, it just used the already existing SWAP space to store it's paged out pages of memory. On the systems I worked on at the time (SunOS / Solaris), paging was a sign of pressure on the physical memory (RAM) of a system, swapping was a sign of _severe_ physical memory pressure. This was a time when we configured 2 to 4 times the amount of physical RAM as SWAP space. RAM was very expensive and hard drives just expensive :-) It was common on a normally operating system to see the page scanner* running up to 100 times per second. A scan rate of over 100 was considered a sign of pressure on RAM that needed to be addressed, any SWAPing was considered a sign that the system needed more physical RAM. Today RAM is so cheap that _any_ paging is often considered bad and an indication that more Ram should be added. *Solaris Page Scanner: This is a kernel level process that wakes up, examines the amount of free RAM, and takes action based on that value. The thresholds are all dynamic and based on the amount of RAM in the system. Above a high water mark the scanner does nothing. As the amount of free RAM drops, various pages of RAM are copied to SWAP space and the RAM freed. Eventually, if the amount of free Ram falls low enough, even parts of the kernel will be paged out. This is very bad and can lead to a system thrashing where it spends the vast majority of it's time just paging in and out and not actually getting anything done. -- Paul Kraus Deputy Technical Director, LoneStarCon 3 Sound Coordinator, Schenectady Light Opera Company ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: swap partition leads to instability?
Follow up comment. It has been pointed out to me that there is Varnish software taking advantage of system VMM and swap space. Well, there are cache-oblivious algorithms that perform as well, and so they make the above (disk access model; cache-aware model) unnecessary (obsolete ?) and are superior in their generality. jb ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: swap partition leads to instability?
On Tue, May 28, 2013 at 8:42 PM, jb jb.1234a...@gmail.com wrote: Follow up comment. It has been pointed out to me that there is Varnish software taking advantage of system VMM and swap space. Well, there are cache-oblivious algorithms that perform as well, and so they make the above (disk access model; cache-aware model) unnecessary (obsolete ?) and are superior in their generality. Note that such cache-oblivious algorithms cannot be trivially applied to any problem. Also, properly written cache-oblivious algorithms tend to recursively decompose the problem until it is small enough to fit in a cache and solve each part iteratively. The improvement effect can be noticed on large inputs. These algorithms will most probably perform quite badly on small inputs. jb ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: swap partition leads to instability?
On 26. mai 2013, at 10:58, M. V. bored_to_deat...@yahoo.com wrote: But recently I heard from a FreeBSD expert that I shouldn't have swap partition for my server, and having swap partition could make my server unstable Any chance this could be a simple misunderstanding? That he objected to the thought of the server swapping on an SSD (or whereever), more than the idea of having the partition itself? If you're heavily swapping on an SSD with no redundancy, sooner or later it will kill your server. Generally though, havin too little memory will also give issues. ;) I usually recommend viewing swap like you view filesystems. If you don't want downtime or dataloss when it dies, plan for failiure, and use gmirror or zfs mirror and zvol. Terje ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: swap partition leads to instability?
jb jb.1234abcd at gmail.com writes: M. V. bored_to_death85 at yahoo.com writes: recently I heard from a FreeBSD expert that I shouldn't have swap partition for my server, and having swap partition could make my server unstable. I think your FB expert was up to something. I bet he spoke out of experience. Swapping by itself can decrease system reliability due to possible data corruption on swap disk or during two-way transfers, with subsequent incorrect RAM and machine crash. But, swapping is also a symptom, not a problem. It is never a good idea to let it get to that point. ... http://blog.jcole.us/2010/09/28/mysql-swap-insanity-and-the-numa-architecture/ Very interesting point. - do you think this could hurt my server's stability too? (most of its work is a noticeable amount of packet-forwarding, and other network services, like firewall, dhcp server, ntp server, etc) - if so, in what conditions? can I do something to prevent this? or should I just get rid of the swap partition? - does swap partition do any good for me at all? I mean if we even suppose nothing bad happens because of it, is it worth risking to keep it? thank you. ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: swap partition leads to instability?
Hi, On Sun, 26 May 2013 01:58:32 -0700 (PDT) M. V. bored_to_deat...@yahoo.com wrote: I have a 24/7 network server/gateway with FreeBSD-8.2 on a SSD drive. it's partitioned as normal (/ , /tmp, /var , /usr and swap) for a long time now. But recently I heard from a FreeBSD expert that I shouldn't have swap partition for my server, and having swap partition could make my server unstable. this was so strange for me, and I searched a lot but couldn't find a reason for this claim. because it is a false claim. I never ever have had any system with working hard, that gave a problem because of the swap space. Erich ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: swap partition leads to instability?
On Sun, 26 May 2013 16:09:06 +0700, Erich Dollansky wrote: Hi, On Sun, 26 May 2013 01:58:32 -0700 (PDT) M. V. bored_to_deat...@yahoo.com wrote: I have a 24/7 network server/gateway with FreeBSD-8.2 on a SSD drive. it's partitioned as normal (/ , /tmp, /var , /usr and swap) for a long time now. But recently I heard from a FreeBSD expert that I shouldn't have swap partition for my server, and having swap partition could make my server unstable. this was so strange for me, and I searched a lot but couldn't find a reason for this claim. because it is a false claim. I never ever have had any system with working hard, that gave a problem because of the swap space. I think the problem here is that he's using a SSD. As soon as the swap partition is being in heavy use, which means it receives many writes, this may lead to the SSD wearing out, decreasing its lifetime. Swap space usually does not make a system unstable. Sometimes, the opposite is true. :-) So if you're using a SSD, you can apply certain optimizations to increase its lifetime so it can be in use for several years (running 24/7). Here are some suggestions -- check if they are useful in your specific case! # newfs -m 0 -i 16384 -b 16384 -f 2048 -U /dev/ada0a This assumes that you don't have created any slices, just one bootable partition covering the whole disk (therefor ada0a). Create a swapfile like this: # /bin/rm -f /swapfile.tmp # /bin/dd if=/dev/zero of=/swapfile.tmp bs=16m seek=1k count=0 # /sbin/mdconfig -a -t vnode -u 0 -f /swapfile.tmp || /bin/sh # /bin/chflags nodump /swapfile.tmp # /bin/rm -f /swapfile.tmp # /sbin/swapctl -a /dev/md0 This makes the system use a disk-backed dynamic swap file. If the swap won't be used, no space will be occupied or reserved on the SSD. You can also think about changing stuff you won't need to store on the SSD, maybe some content of /tmp or /var. You can also put those into a memory disk. The SSD rule is: Minimize writes if you can. This is a _general_ rule and does not correspond to swap only! -- Polytropon Magdeburg, Germany Happy FreeBSD user since 4.0 Andra moi ennepe, Mousa, ... ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: swap partition leads to instability?
On Sun, 26 May 2013 01:58:32 -0700 (PDT) M. V. bored_to_deat...@yahoo.com wrote: hi everyone, I have a 24/7 network server/gateway with FreeBSD-8.2 on a SSD drive. it's partitioned as normal (/ , /tmp, /var , /usr and swap) for a long time now. But recently I heard from a FreeBSD expert that I shouldn't have swap partition for my server, and having swap partition could make my server unstable. this was so strange for me, and I searched a lot but couldn't find a reason for this claim. so my question is simple: - could having a swap partition, be a bad thing for my FreeBSD server? and if so, why and in what conditions? I never had a problem with swap partitions, but perhaps the FreeBSD expert may refer to one of this three issues I can think about problems with swap, none of them are unstability issues: a) Swap partitions may store info from previous boot, you can use swap encryption for that. b) When using swap files (mounting a swap in a file), at shutdown sometimes there's a race condition and swap is unmounted before it's empty. c) If your system needs to use swap, network apps may show/throw timeouts when swap i/o is heavy. Sometimes b) kicks me but it's my fault because i don't shutdown process properly. Cheers! L --- --- Eduardo Morras emorr...@yahoo.es ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: swap partition leads to instability?
Hi, sorry for my English. Here is what I wanted to say. On Sun, 26 May 2013 16:09:06 +0700 Erich Dollansky erichsfreebsdl...@alogt.com wrote: Hi, On Sun, 26 May 2013 01:58:32 -0700 (PDT) M. V. bored_to_deat...@yahoo.com wrote: I have a 24/7 network server/gateway with FreeBSD-8.2 on a SSD drive. it's partitioned as normal (/ , /tmp, /var , /usr and swap) for a long time now. But recently I heard from a FreeBSD expert that I shouldn't have swap partition for my server, and having swap partition could make my server unstable. this was so strange for me, and I searched a lot but couldn't find a reason for this claim. because it is a false claim. I never ever have had any system with working hard, that gave a problem because of the swap space. I never ever have had any system which was working hard that gave problems because of the swaps space. Erich Erich ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: swap partition leads to instability?
On 26/05/2013 09:58, M. V. wrote: hi everyone, I have a 24/7 network server/gateway with FreeBSD-8.2 on a SSD drive. it's partitioned as normal (/ , /tmp, /var , /usr and swap) for a long time now. But recently I heard from a FreeBSD expert that I shouldn't have swap partition for my server, and having swap partition could make my server unstable. this was so strange for me, and I searched a lot but couldn't find a reason for this claim. so my question is simple: - could having a swap partition, be a bad thing for my FreeBSD server? and if so, why and in what conditions? Having a swap partition is absolutely standard for server or workstation class machines, and should be implemented as a matter of course. Even if the machine has much more memory than it would generally ever use and so have no actual need to swap. About the only circumstances where you wouldn't want swap is if you were creating an embedded appliance and eg. didn't have any writable disk space. That's pretty extraordinary and as such a system would have to be heavily customized over stock FreeBSD anyhow, so not having swap would fade into insignificance compared to the other changes that would be required. Why is swap needed? Nowadays, memory is sufficiently cheap and system boards are capable of loading so much of it, that the only sensible strategy is to have more physical RAM than is required to keep your normal application load working. So a swap partition should not be routinely involved in swapping memory pages back and forth. Even so, idle pages can be swapped out -- there's no point in having an unreferenced memory page sitting in RAM taking up space that could be used productively by an active process. A small amount of swap usage like this is standard. A large amount of swap usage like this indicates you need to switch to using better written software. Swap is also useful to buffer against unexpected spikes in memory usage. Sure, performance generally nosedives once a system starts actively swapping, but that may be a better outcome than the alternative if there is no swap capacity available: which is for the kernel to start killing off processes in an attempt to reduce memory pressure. Finally, swap is used as the place to record kernel state in the event of system crashes. You could use any otherwise unused disk partition for that, but swap is traditional. This is where the hoary old recipe of 'swap = twice ram' came from, although nowadays what with minidumps and the generally larger amounts of RAM in use you don't need to provide anything like as much as that. If you're bothered by having a few GiB of disk allocated as swap but basically idle, then look into tmpfs or mdmfs for /tmp -- that will let you make productive use the space while still keeping the ability to save crashdumps if needed. Some caveats about where to put a swap area: * If your system is under memory pressure, then your swap area can be extremely active. In these circumstances putting swap on a SSD card or other device with a limited number of write-cycles is not a good choice. * If you are using ZFS, and again, if you are under memory pressure, then putting swap on a ZFS can lead to a deadlock where the system needs to allocate more memory to deal with an out-of-memory condition. In this case, it is recommended to create a separate swap partition not managed by ZFS. Otherwise, swap can go anywhere. A dedicated partition will give better performance than swapping to a file, but file-backed swap is handy if you need to add swap in a hurry. For resilience, mirror swap partitions in pairs -- gmirror(8) is a good tool for that. Don't try using any of the higher RAID levels for swap areas -- their performance characteristics are not a good match to the sort of IO a swap area does. For best performance, you should spread swap areas over as many disk spindles as possible. You can create numerous swap areas and the system will automatically stripe any IO across them. Cheers, Matthew -- Dr Matthew J Seaman MA, D.Phil. PGP: http://www.infracaninophile.co.uk/pgpkey signature.asc Description: OpenPGP digital signature
Re: swap partition leads to instability?
M. V. bored_to_death85 at yahoo.com writes: hi everyone, I have a 24/7 network server/gateway with FreeBSD-8.2 on a SSD drive. it's partitioned as normal (/ , /tmp, /var , /usr and swap) for a long time now. But recently I heard from a FreeBSD expert that I shouldn't have swap partition for my server, and having swap partition could make my server unstable. this was so strange for me, and I searched a lot but couldn't find a reason for this claim. so my question is simple: - could having a swap partition, be a bad thing for my FreeBSD server? and if so, why and in what conditions? Cheers! Hi, I think your FB expert was up to something. I bet he spoke out of experience. Swapping by itself can decrease system reliability due to possible data corruption on swap disk or during two-way transfers, with subsequent incorrect RAM and machine crash. But, swapping is also a symptom, not a problem. It is never a good idea to let it get to that point. Badly written, architected, or tuned server app or system are the reason. Think of RDBMS/SQL server processing real-time on-line transactions and how much it goes into setting it up properly for a heavy use. On a smaller scale, consider this example: http://blog.jcole.us/2010/09/28/mysql-swap-insanity-and-the-numa-architecture/ jb ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: swap partition leads to instability?
The Intel SLC mSATA drives I use in embedded devices don't support TRIM, but - it doesn't seem to matter. Actually, I'm confident that just using bare partitions for swap is fine, and I haven't had any of the trouble I witnessed with MLC devices. The difference is that the size is limited to under 32GB. - M On Sun, May 26, 2013 at 4:32 PM, Warren Block wbl...@wonkity.com wrote: On Sun, 26 May 2013, Polytropon wrote: On Sun, 26 May 2013 16:09:06 +0700, Erich Dollansky wrote: Hi, On Sun, 26 May 2013 01:58:32 -0700 (PDT) M. V. bored_to_deat...@yahoo.com wrote: I have a 24/7 network server/gateway with FreeBSD-8.2 on a SSD drive. it's partitioned as normal (/ , /tmp, /var , /usr and swap) for a long time now. But recently I heard from a FreeBSD expert that I shouldn't have swap partition for my server, and having swap partition could make my server unstable. this was so strange for me, and I searched a lot but couldn't find a reason for this claim. because it is a false claim. I never ever have had any system with working hard, that gave a problem because of the swap space. I think the problem here is that he's using a SSD. As soon as the swap partition is being in heavy use, which means it receives many writes, this may lead to the SSD wearing out, decreasing its lifetime. Another problem with SSDs is that they can have difficulty with wear leveling. This is even worse with swap because there is no way to use TRIM to tell the SSD about blocks that have been freed. The workaround is a swapfile on UFS with TRIM enabled. It works fine, and even better when you update the rc scripts for shutdown. Here's an article on setup: http://www.wonkity.com/~**wblock/docs/html/ssd.htmlhttp://www.wonkity.com/~wblock/docs/html/ssd.html And here is the PR with a patch: http://www.freebsd.org/cgi/**query-pr.cgi?pr=bin/168544http://www.freebsd.org/cgi/query-pr.cgi?pr=bin/168544 __**_ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/**mailman/listinfo/freebsd-**questionshttp://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-** unsubscr...@freebsd.org freebsd-questions-unsubscr...@freebsd.org ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: swap partition leads to instability?
On Sun, 26 May 2013, Polytropon wrote: On Sun, 26 May 2013 16:09:06 +0700, Erich Dollansky wrote: Hi, On Sun, 26 May 2013 01:58:32 -0700 (PDT) M. V. bored_to_deat...@yahoo.com wrote: I have a 24/7 network server/gateway with FreeBSD-8.2 on a SSD drive. it's partitioned as normal (/ , /tmp, /var , /usr and swap) for a long time now. But recently I heard from a FreeBSD expert that I shouldn't have swap partition for my server, and having swap partition could make my server unstable. this was so strange for me, and I searched a lot but couldn't find a reason for this claim. because it is a false claim. I never ever have had any system with working hard, that gave a problem because of the swap space. I think the problem here is that he's using a SSD. As soon as the swap partition is being in heavy use, which means it receives many writes, this may lead to the SSD wearing out, decreasing its lifetime. Another problem with SSDs is that they can have difficulty with wear leveling. This is even worse with swap because there is no way to use TRIM to tell the SSD about blocks that have been freed. The workaround is a swapfile on UFS with TRIM enabled. It works fine, and even better when you update the rc scripts for shutdown. Here's an article on setup: http://www.wonkity.com/~wblock/docs/html/ssd.html And here is the PR with a patch: http://www.freebsd.org/cgi/query-pr.cgi?pr=bin/168544 ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: swap partition leads to instability?
On Sun, May 26, 2013 at 6:32 PM, Warren Block wbl...@wonkity.com wrote: Another problem with SSDs is that they can have difficulty with wear leveling. This is even worse with swap because there is no way to use TRIM to tell the SSD about blocks that have been freed. Um, that is wrong. It is in fact the basically the point of TRIM. And SSD's typically use the best form of wear leveling and it's usually advisable to leave a bit of the drive unpartitioned/unused to ensure the wear leveling works optimally. -- Adam Vande More ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: swap partition leads to instability?
On Sun, 26 May 2013, Adam Vande More wrote: On Sun, May 26, 2013 at 6:32 PM, Warren Block wbl...@wonkity.com wrote: Another problem with SSDs is that they can have difficulty with wear leveling. This is even worse with swap because there is no way to use TRIM to tell the SSD about blocks that have been freed. Um, that is wrong. Which part? A FreeBSD swap partition has no way to use TRIM, so I suggest using a swap file on top of UFS, which does support TRIM. It is in fact the basically the point of TRIM. And SSD's typically use the best form of wear leveling and it's usually advisable to leave a bit of the drive unpartitioned/unused to ensure the wear leveling works optimally. Using TRIM should preserve performance better than leaving unused space and letting the drive wear leveling algorithm move data around without the hint. ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: swap partition leads to instability?
On Sun, May 26, 2013 at 7:20 PM, Warren Block wbl...@wonkity.com wrote: Which part? This part: Another problem with SSDs is that they can have difficulty with wear leveling. Do as I suggested and you'll get maximum life from the drive even with swap present. Even absent of best practices, SSD's in general do a great job in managing wear leveling. We're 5+ years out from crappy SSD's with dynamic wear leveling. Modern SSD's don't suffer nearly the write amplification effect of earlier drives. Also the write amplification effect only comes into play during random writes. A lot of common swap usage isn't random. All this is of course assuming we're dealing with a quality drive. If you're using a cheap Chinese knock off, all bets are off. A FreeBSD swap partition has no way to use TRIM, so I suggest using a swap file on top of UFS, which does support TRIM. Using TRIM should preserve performance better than leaving unused space and letting the drive wear leveling algorithm move data around without the hint. Normal dynamic wear leveling on a modern SSD will be better than imposing an FS- backed swap for 4GB partion occupying a small fraction of total drive space. File backed paging imposes two sets of bottlenecks and TRIM only *helps* with one. Another part of the equation is how much is swap used. If rarely, this is a non-issue to begin with. If it's significant, any flash SSD probably isn't appropriate. Certain other SSD's are not subject to these guidelines at all. -- Adam Vande More ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org