swap
Size: 1143
Comment:
|
Size: 3224
Comment:
|
Deletions are marked like this. | Additions are marked like this. |
Line 1: | Line 1: |
Swap space on a hard drive has been with Linux from almost the begining. Ram was very expensive and swap let things like kernel building happen. However, the use of swap to disk during audio tasks is the death of the track being recorded, or a noticable audio glitch in a live performance. | Swap space on a hard drive has been with Linux from almost the beginning. Ram was very expensive and swap let things like kernel building happen. However, the use of swap to disk during audio tasks is the death of the track being recorded, or a noticeable audio glitch in a live performance. |
Line 5: | Line 5: |
* UbuntuStudio already gives audio applications the right to use "memory locking". That is, they can tell the OS their data in RAM must not be swapped out. Good first step. However, I have found that one audio app that has no lock will freeze Jackd while it cycles it's ram back in. Jackd is trying to output a bit of ram that is on disk just now... and all sound stops. | * UbuntuStudio already gives audio applications the right to use "memory locking". That is, they can tell the OS their data in RAM must not be swapped out. Good first step. However, I have found that one audio app that has no memlock will freeze Jackd while it cycles it's ram back in. Jackd is trying to output a bit of ram that is on disk just now... and all sound stops. |
Line 8: | Line 8: |
* Swappiness: This is a variable the kernel uses to decide how full the memory has to be before it stats swapping out bits of memory that are now being used right now. It is based on what is left. The standard Ubuntu setting (an most others) is 60. That is when there is 60% ram left, the kernel starts swaping things out. This is a great setting for a server (the mysql people seem to disagree) but not for a desktop and really bad for audio work. | * Swappiness: This is a variable the kernel uses to decide how full the memory has to be before it starts swapping out bits of memory that are now being used right now. It is based on what is left. The standard Ubuntu setting (an most others) is 60. That is when there is 60% ram left, the kernel starts swapping things out. This is a great setting for a server (the mysql people seem to disagree) but not for a desktop and really bad for audio work. The Linuxmusicians page recommends a setting of 10 and some people recommend a setting of 1 just for normal desktop work. This does seem to help. * zram: This is a utility that takes some of the ram space and makes a compressed swap space in ram. It can take a 2Gig ram and make it look like 3Gig or more. This compressed swap space is ''much'' faster than disk swap and makes the desktop more responsive even if an app has been moved to this ram swap. However, for audio even this much faster swap is too slow and there can be a discernible audio drop out if one of the audio samples happens to be swapped out. This could be a partial answer for things like qjackctl that can be swapped out but need to respond to user input quite quickly for things like making connection changes. * swapoff: How about just turning swap off? There are two reasons not to turn off swap. If Linux goes into hybernation it uses disk swap to hold it's state while the power is off, so no swap means no hybernation. Also, when ram is full, the kernel starts Killing apps or won't let you start them. My answer? Lets say I have 1Gig of Ram and 1Gig of swap (actually that is what I have). That is 2Gig, after that the kernel will shut things off anyway... but I will probably kill stuff before then because of swapping death. I could just go out and buy another Gig of Ram and have a responsive system till I run out. My thought is that it is better for the kernel not to let me start working than for swap to spoil the "perfect take". * More Ram: With Ram prices today, this should be a no brainer. Get more Ram! This should probably be the first tweak in the list. * A memlock wrapper to use on audio apps without their own memlock... Does such a thing exist? My guess is that more Ram and swappiness set to 1 or even 0 would be the best start. Trying to use zram may be a help too if the user is careful to keep essential audio tasks from going in there. I don't know if this is possible. Turning swap off while recording might be something to try too. More testing needed. |
Swap space on a hard drive has been with Linux from almost the beginning. Ram was very expensive and swap let things like kernel building happen. However, the use of swap to disk during audio tasks is the death of the track being recorded, or a noticeable audio glitch in a live performance.
What can be done?
UbuntuStudio already gives audio applications the right to use "memory locking". That is, they can tell the OS their data in RAM must not be swapped out. Good first step. However, I have found that one audio app that has no memlock will freeze Jackd while it cycles it's ram back in. Jackd is trying to output a bit of ram that is on disk just now... and all sound stops.
- Swappiness: This is a variable the kernel uses to decide how full the memory has to be before it starts swapping out bits of memory that are now being used right now. It is based on what is left. The standard Ubuntu setting (an most others) is 60. That is when there is 60% ram left, the kernel starts swapping things out. This is a great setting for a server (the mysql people seem to disagree) but not for a desktop and really bad for audio work. The Linuxmusicians page recommends a setting of 10 and some people recommend a setting of 1 just for normal desktop work. This does seem to help.
zram: This is a utility that takes some of the ram space and makes a compressed swap space in ram. It can take a 2Gig ram and make it look like 3Gig or more. This compressed swap space is much faster than disk swap and makes the desktop more responsive even if an app has been moved to this ram swap. However, for audio even this much faster swap is too slow and there can be a discernible audio drop out if one of the audio samples happens to be swapped out. This could be a partial answer for things like qjackctl that can be swapped out but need to respond to user input quite quickly for things like making connection changes.
- swapoff: How about just turning swap off? There are two reasons not to turn off swap. If Linux goes into hybernation it uses disk swap to hold it's state while the power is off, so no swap means no hybernation. Also, when ram is full, the kernel starts Killing apps or won't let you start them. My answer? Lets say I have 1Gig of Ram and 1Gig of swap (actually that is what I have). That is 2Gig, after that the kernel will shut things off anyway... but I will probably kill stuff before then because of swapping death. I could just go out and buy another Gig of Ram and have a responsive system till I run out. My thought is that it is better for the kernel not to let me start working than for swap to spoil the "perfect take".
- More Ram: With Ram prices today, this should be a no brainer. Get more Ram! This should probably be the first tweak in the list.
- A memlock wrapper to use on audio apps without their own memlock... Does such a thing exist?
My guess is that more Ram and swappiness set to 1 or even 0 would be the best start. Trying to use zram may be a help too if the user is careful to keep essential audio tasks from going in there. I don't know if this is possible. Turning swap off while recording might be something to try too. More testing needed.
UbuntuStudio/audio-settings/swap (last edited 2012-05-24 13:37:14 by len-ovenwerks)