VMware Communities
bemymonkey
Contributor
Contributor

Can I make VMWare Player write to .vmdk and .vmem files continuously instead of only when I suspend the VM?

Hi there,

I've been using VMWare Player for a whole bunch of stuff lately, and one thing *really* bothers me:

When I suspend a VM with 2GB of RAM, my work computer locks up for about 5-10 minutes while VMWare writes to the various VMDK and VMEM files. During this time, it literally takes 100+ seconds to open a Windows Explorer window or open the task manager, and the hard drive LED lights up continuously...

Since this is a work machine, I can't just replace the hard drive with an SSD and be done with it, so I'm looking for a software-based workaround. Is there a way to make the VM keep these files continuously up to date (with low priority writes) while the VM is running so that the suspend process will be less painful?

Any ideas? Thanks in advance!

0 Kudos
4 Replies
a_p_
Leadership
Leadership

Not that I would know of. When you suspend the VM, the active memory has to be saved, which may - depending on the amount of configured guest memory and the speed of your local disk - take longer than to cleanly power off the VM.

André

rocket888
Contributor
Contributor

I too see this behavior - my workaround (to avoid waiting 3-5 minutes for the system to recover) is to go into (host) standby and then immediately resume. This seems to cause the flushing to occur much faster, at the full rate my disk drives can go. For a 1.6 gig guest, it takes about 10-20 seconds longer to go to standby and when I resume, I see that physical memory that was used by the VM is now also freed up (but has probably been moved to the disk cache).

Since I now run my VM on an SSD, I tend to do a shutdown instead of a suspend, since I don't want to write to the SSD disk that often. That also solves the problem.

Without going into the details of how the system handles memory mapped files such as the .vmem file, it appears that after vmplayer does a suspend, it then exits with all the modified pages of physical memory (backed by the .vmem file) still needing to be written to disk. It would appear that this flushing activity is not done all at once, rather, it occurs over a long period of time (a few minutes). This seems to be what is causing the thrashing. I see this especially if I try to copy the VM directory somewhere too quickly after suspending a VM.

However, if you go to (host) standby, it seems that windows will then push this modified memory to disk at a much higher (more efficient) rate. Perhaps it does much larger writes whereas otherwise only a few pages at a time get written otherwise.

If you do a VM shutdown, then the virtual memory need not be saved and the .vmem file is deleted. It's been many years since I wrote code that did that sort of file mapping in windows. There must be a way to free up a memory mapped modified file without having to flush it first. Thus after a shutdown (instead of suspend) all physical memory is freed up instantly and the system doesn't thrash.

On the other hand, I've always been a bit puzzled at what is going on when you exit a VM and it says it's saving state. It clearly isn't writing all of memory to the .vmem file, but is relying on the system to do so after the program exits. In addition, if you resume a suspended VM (before doing other things), it restores its state almost instantly, since most of the .vmem file is still in physical memory and need not be read back from disk.

How the virtual disks are managed is unknown to me. Perhaps they too are memory mapped and the same sort of thing is going on there too.

bemymonkey
Contributor
Contributor

I'll give that a try on Monday, thanks. Smiley Happy

I'm also wondering why disk thrashing is such a huge issue when disk writes are only ~3-5MB/sec... as you've said, the process takes ages because the writes are so slow, and speeding them up to the max. wite speed of the disk (say 40-50MB/sec on an average hard drive running a full Windows sytem with background tasks and all) would make the whole process take only 20 seconds or so.... but isn't the point of writing slowly to *not* lock up the system? When other programs write to disk at this speed, I hardly even notice it. Maybe VMEM files are written extremely randomly, with very few sequential blocks?

0 Kudos
rocket888
Contributor
Contributor

Depending on your host, the sysinternals tool rammap has a menu option to empty various lists. I suspect you could also use this to empty the modified page list.

This tool requires vista or above, and so I could not test it as my host is xp. But I did experiment with it in my win8 guest.

http://technet.microsoft.com/en-us/sysinternals/ff700229

The author also explains windows memory management (using this tool and others) and much else  here:

http://channel9.msdn.com/Events/Speakers/Mark-Russinovich

(see mysteries of memory management part 1-2)

0 Kudos