Table of Contents

About

When running multiple virtual machines concurrently, such as we do for the VIBE group, resources become quite limited in terms of CPU power. VIBE uses the Clockwerk in order to power a hypergrid-net with a connected-graph like architecture where there is no central point of failure. We have found in practicality that the net-like architecture of hyerpgrids is favorable to grid services, due to the fact that each connected grid can keep its autonomy, such that when one grid goes down, the others still remain functional.

However, running a bunch of virtual machines consumes a massive amount of resources. For example, a simple script such as a script that is meant to commute between two colors occupies up to %50 of CPU on a dual-core machine.

We have observed that not all the grids are used at the same time and whilst some lay dormant, the rest lay dormant and just use up CPU cycles with no avatar around to observe what is going on. There are cases where VIBE runs computational simulations, where the grid has to be up and running regardless if agents are around, yet most of the time some of the grids are used for teaching and vacant otherwise.

To harness the full power of the cores we have available, we have chosen to put the machine to sleep (an idea originally inspired from the Kitely grid) such that vacant virtual machines (grids) are suspended until an avatar connects.

Diagram

A rough illustration of the suspending mechanism can be seen in the image below:

Using iptables, we monitor port tcp 9000 using the xt_IDLETIMER iptables target. Using the following rule for xt_IDLETIMER:

iptables -A INPUT -i eth0 -p tcp --dport 9000 -j IDLETIMER --timeout 60 --label spectacledowl

instructs the kernel to update the file at /sys/class/xt_idletimer/timers/spectacledowl every second, counting down from 60 to 0. Whenever traffic is sensed on the interface eth0 on TCP port 9000, the kernel will update that file to its initial value of 60, and will then start counting down again. If you want, the –timeout parameter acts as an alarm, decreasing until it reaches 0.

Next, we use a script (written in PHP to be in-theme with other OpenSim assets) to poll the file at /sys/class/xt_idletimer/timers/spectacledowl, and check whether the timer has reached zero.

The actual suspending and resuming of the virtual machine is performed by the script that sends the SIGSTOP to pause OpenSim, respectively SIGCONT to resume OpenSim. While OpenSim is suspended, it does not consume any CPU cycles and lets the other grids grab more CPU from the host machine.

Performance

We essentially run 12 Spectacled Owls that consume less than 20% CPU when no avatar is present on the scene - this would be contrasted to OpenSim's behavior of utilizing 50% of the CPU by just running a single color-fader script.

Code

opensimpm
#!/usr/bin/php
<?php
 
/////////////////////////////////////////////////////////////
// Wizardry and Steamworks (c) grimore.org - 2014, License: MIT //      
//                                                         //
// Permission is hereby granted, free of charge, to any    //
// person obtaining a copy of this software and associated //
// documentation files (the "Software"), to deal in the    //
// Software without restriction, //including without       //
// limitation the rights to use, copy, modify, merge,      //
// publish, distribute, sublicense, and/or sell copies of  //
// the Software, and to permit persons to whom the         //
// Software is furnished to do so, subject to the          //
// following conditions:                                   //
//                                                         //
// The above copyright notice and this permission notice   //
// shall be included in all copies or substantial portions //
// of the Software.                                        //
//                                                         //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF   //
// ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT         //
// LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS   //
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO     //
// EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE  //
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER      //
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING    //
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR      //
// THE USE OR OTHER DEALINGS IN THE SOFTWARE.              //
/////////////////////////////////////////////////////////////
 
if(!defined('STDIN')) {
    print 'This script is meant to be run on the command line.'."\n";
    return 1;
} 
 
$pid = `pidof mono`;
// process does not exist, so abort
if(strlen($pid) == 0) {
    return 0;
}
 
$countdown = file_get_contents(
		'/sys/class/xt_idletimer/timers/spectacledowl'
	);
// the file could not be found, bail
if($countdown ==== FALSE) {
    return 0;
}
 
switch($countdown) {
    case 0:
	//suspend
        $stat = `ps --no-headers -o stat -C mono | grep T`;
        // process already suspended, so abort
       if(strlen($stat) != 0) {
           return 0;
       }
       `kill -s STOP $pid`;
       break;
    default:
      //resume
      `kill -s CONT $pid`;
      break;
}

opensim/suspend_and_resume.txt · Last modified: 2022/04/19 08:28 by 127.0.0.1

Access website using Tor Access website using i2p Wizardry and Steamworks PGP Key


For the contact, copyright, license, warranty and privacy terms for the usage of this website please see the contact, license, privacy, copyright.