Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

Is a swap partition useful with a VM in VMWare Player?

If none of the specific sub-forums seem right for your thread, ask here.
Post Reply
Message
Author
MagicPoulp
Posts: 431
Joined: 2018-11-05 21:30

Is a swap partition useful with a VM in VMWare Player?

#1 Post by MagicPoulp »

I am running debian using a virtual machine inside VMWare Player with a Windows 10 host.

--> Is it useful to have a partition for the swap with such a setting?

I am not talking about the case for which I would reach the 100% memory use and the swap will allow to use more memory. I am talking about the fact that the swap is used as an automated cache buffer. If you never reach the 100% memory use, the swap is still used to store things you don't use often. This is why the swap is always recommended to have.

However, in a VMWare VM, the disk is special. It is located in file in FAT32 format on the WIndows disk. Therefore. the swap would not work fast.

CwF
Global Moderator
Global Moderator
Posts: 2638
Joined: 2018-06-20 15:16
Location: Colorado
Has thanked: 41 times
Been thanked: 192 times

Re: Is a swap partition useful with a VM in VMWare Player?

#2 Post by CwF »

I'll chime in with some generalities since I'm opposite your case.

I run VM's under a Debian KVM host. For windows guest I have one with swap and one without. For Debian and frankendebian guest all are on a common base image which is a single partition. I have never needed to enable a swap file. Firefox and Liferea and perhaps handbrake seem unstable with minimum memory. I'm sure your exact use case will determine the need, but setting swappiness and using a swap file should give you an indication. Generally I think you don't really need one, but I've tested with swappiness=10 and a swap file, and it does get trickles of use. Those trickles don't seem to slow anything noticeably in the case of plentiful memory. In the end I don't use any swap anymore.

Your point is true though that swap file use with and without ample memory are two different scenarios.

p.H
Global Moderator
Global Moderator
Posts: 3049
Joined: 2017-09-17 07:12
Has thanked: 5 times
Been thanked: 132 times

Re: Is a swap partition useful with a VM in VMWare Player?

#3 Post by p.H »

MagicPoulp wrote:Is it useful to have a partition for the swap with such a setting?
As useful as on real hardware.
MagicPoulp wrote:However, in a VMWare VM, the disk is special. It is located in file in FAT32 format on the WIndows disk. Therefore. the swap would not work fast.
As fast as the rest of the virtual disk. No swap means less free memory for filesystem cache means more disk access.

MagicPoulp
Posts: 431
Joined: 2018-11-05 21:30

Re: Is a swap partition useful with a VM in VMWare Player?

#4 Post by MagicPoulp »

I tried it without swap. And I am very satisfied with the performance for what I have to do: coding, compiling, building, running a server, opening a web browser.

Not having a swap made me save disk space. I am already short in space on my computer.

MagicPoulp
Posts: 431
Joined: 2018-11-05 21:30

Re: Is a swap partition useful with a VM in VMWare Player?

#5 Post by MagicPoulp »

p.H wrote:No swap means less free memory for filesystem cache means more disk access.
Can you explain why no swap means less memory when we never reach the top limit of memory usage (assume 4GB)?

I was thinking the swap will store cache information about memory use to optimize memory usage. But this is quite obscure for me.

MagicPoulp
Posts: 431
Joined: 2018-11-05 21:30

Re: Is a swap partition useful with a VM in VMWare Player?

#6 Post by MagicPoulp »

p.H wrote:No swap means less free memory for filesystem cache means more disk access.
An aswer to my request for clarification would be appreciated. Thank you.

CwF
Global Moderator
Global Moderator
Posts: 2638
Joined: 2018-06-20 15:16
Location: Colorado
Has thanked: 41 times
Been thanked: 192 times

Re: Is a swap partition useful with a VM in VMWare Player?

#7 Post by CwF »

I wrote
Your point is true though that swap file use with and without ample memory are two different scenarios.
If you are out of memory then a swap file will free some of that, then that freed memory can be used for file cache. If you have gigs free then the swap buys little if any advantage.

MagicPoulp
Posts: 431
Joined: 2018-11-05 21:30

Re: Is a swap partition useful with a VM in VMWare Player?

#8 Post by MagicPoulp »

I think there is an important use case for automatic caching when never using more than 50% of real physical RAM. This is also related to why the debian installer recommends to have a swap. Reserving 10% of the disk for a swap partition takes a lot of disk space.

On windows, there is no swap partition.

But I don't think I will have a clear view about this so called cache optimization. I would need to read the source code. But I don't know how to find it. Can someone help me to find the source code of the swap?

p.H
Global Moderator
Global Moderator
Posts: 3049
Joined: 2017-09-17 07:12
Has thanked: 5 times
Been thanked: 132 times

Re: Is a swap partition useful with a VM in VMWare Player?

#9 Post by p.H »

Of course a swap space is useful only under memory pressure. Without available swap space, the system has no choice but discard cached filesystem data or metadata, which may be needed sooner or later and would cause more disk access to be read again.
With available free swap space, the system has the choice of swapping process data which have not been used recently and may not be used again until the process terminates, instead of discarding more recently used filesystem cache. So a few I/O to swap out unused data may save many disk I/O between the cache and the disk.
MagicPoulp wrote:On windows, there is no swap partition.
Windows has a swap file. It's worse.

Post Reply