Planimate State Save using VMWare

From Planimate Knowledge Base
Jump to navigation Jump to search

Planimate and State Save


Over the years a number of requests for "model state save" have been made but this hasn't been implemented as it requires a significant rewrite of the runtime data structures, including the FEC, items, attribute reference caches, runtime routing tables and many more. These structures get created when the run engine starts and were designed for speed of execution, not saving/reloading.


My recent testing of the VMWare 4.5 software product (www.vmware.com) has shown that it may well fill the need in giving a developer a "state save" capability in Planimate.

About VMWare


VMWare runs as an application on a real ("host") PC system. Within its window, it creates an entire PC (the "guest"), supporting full resolution graphics, mouse, sound, cdroms and USB. You can "full screen" a virtual machine and you can sometimes forget its not the "real" system - until an ICQ arrives (on the host) while Windows is still booting on the guest :)


For the hard drive of the guest PC, VMWare uses normal (but fairly large) files on the host. This means a guest can be backed up (say to DVD) and moved to a different PC (with VMWare installed) and restarted with no configuration change. A host PC can also run several guest PCs simultaneously.


VMWare has a "suspend/resume" function which can save a guest and continue it later (like suspending a laptop). This is great for quickly bringing up a test PC to try some software on, for example.


The most recent enhancement of interest however is the "Snapshot" and "Revert" function. Using these, the state of whatever is running can be captured and then restored. Save time with a loaded model is under a minute and restore time even faster.

Configuring for best performance

The following suggestions should help improve performance of Planimate within this environment, with the specific aim of using VMWare to save and restore state when trying to track down a bug which takes a long time to "run up" to.

The Guest PC


- If an option, use Win2k as the guest OS, its more lightweight memory wise.

  • Set up the guests "ram" in VMWare to enough to accomodate the model being debugged but not too much more. I suggest a minimum of 384MB
  • Set up the guests hard disk to say 2GB and put it on your fastest hard drive (see below)
  • Follow VMWare's advice and install the VMWare Tools in the guest system - very important for performance and ease of use
  • Dont install unnecessary programs in the guest system, keep it lean. Disable unneeded services if you're into that sort of thing.
  • (optional) Configure the VMWare's guest OS to 1 resolution below your current screen, then you can see the entire virtual machine desktop in a window
  • Ensure the guest is configured for hicolor at least
  • In the guest OS's display properties, ensure all the special effects are off (eg: Window fades, full window drag)
  • Set the guest's OS's Virtual Memory settings (system properties-advanced-performance) to the minimum. The guest should never be driven into swapping ("give" the guest PC more "RAM" if it needs it).
  • Use "host only" networking and keep the guest off the internet. If you give the guest internet access, realise that the OS will be vulnerable to attack and you must fully patch it and take normal precautions before it gets internet access (unless you have a separate firewall).
  • IMPORTANT Its OK to set up network shares between the guest and its host but IF you are going to use the State Save Snapshot/Revert functionality then DONT run EXEs, models or access data over the shared network connection - copy all EXEs and data accessed to the guests C drive first. Otherwise you will get crashes due to the EXE not being able to find itself on a revert and corrupted data if the model wrote data files that need to be "undone" by the revert operation.
    - IMPORTANT - any work/changes made to files on the guest PC's virtual hard drive since a Snapshot will disappear when a R/evert is done.

    The Host PC


- Needs a hard drive with a couple of GB free on which to place the guest PC's hard disk file

  • The hard disk should be the fastest drive in the system (preferably 7200 RPM)
  • The drive should be defragmented before starting with VMWare
  • The drive should be running at least UDMA mode 5, if not your system is old, misconfigured or you're on a laptop.
  • Should have at least 512MB of RAM
  • Should not have any time consuming tasks running

    Performance


"""Model run times"""I get very similar run times on the guest and on the real PC. In some tests, the guest was even faster than the real PC but perhaps that could be because VMWare was loaded (but idle) when I did the test, it has more aggessive task scheduling, or maybe because my guest OS is Win2K and the host is XP.

Its interesting to know that VMWare does not "emulate" the CPU. It actually gives the CPU to the guest and takes control again whenever the guest accesses what it thinks is hardware/kernel space but is in fact the emulation layer that VMWare imposes. This means that CPU intensive software (like Planimate in Advance To Time mode) has very little overhead when running under VMWare. I never expected this and in older versions had experienced slower performance which I accepted as inevitable.

The guest boots very quickly because its working off a virtual hard drive which can have a very large cache (the real RAM caching of the hard disk file done by the host OS)

Having plenty of RAM on the host will make a big difference to the performance of the guest particularly in reverts, which seem to be nicely cached - eg: in my testing, snapshot/save state of a paused model using 30MB of RAM took about 20 seconds and restoring it after messing around for a few minutes took about 2 seconds.




idkbase note 219