Lag Radar HUD - SLUniverse Forums
Old 11-10-2011, 01:02 PM   #1 (permalink)
Banned
 
Join Date: Mar 2011
Location: Pennsylvania
Posts: 1,213
SL Join Date: Jan 2007
Post Lag Radar HUD

This is a radar HUD that will show you detailed resource usage information at a glance, and more detailed resource usage information if you click on the name of a region or on an agent name. Here's a picture of it:



To make it you need to rez a box, resize it to <0.1, 0.2, 0.03> then copy it vertically upwards with about 0.04 meters between each prim. Link them in order from the top to the bottom so that the bottom prim is root and the one above it is the first child then the one above that is the second child and so forth. I also got rid of the textures on the prims and set them to black with a transparency of 50%. Take this into your inventory and attach it as a HUD and then drop the script in it.

If you don't feel like doing that you can get it for free in the SL marketplace:
Lag Radar HUD 1.0

If you have any suggestions at all on how to measure resource usage better please let me know or post your tweaks in this thread. I'd especially love to hear feedback on how to make the interface better and how to do the colors better. I know that what constitutes high vs medium vs low lag is debatable.

Here's a quick manual on how it works. I'll post the code separately, below this post.

===AVATAR NUMBERS===
**m**
This is how far somebody is from you in meters.

**scripts**
This is how many scripts a person is wearing.

**Mb**
This is how much memory has been allocated to this avatar for their scripts to run. This is not how much memory they are using, it is just how much memory they can use with their scripts. This is a common measure of how laggy somebody is. Less than 2Mb is very good, over 6Mb is bad, and over 12Mb is horrible.
LSL Script Memory - Second Life Wiki

**MicroSec**
This is how much processor time a person's scripts are taking up, in microseconds. It is estimated by looking at how much processing time the person has been taking up over the last 30 minutes and averaging all of that, so while it changes constantly, this does not actually show how much processor time is currently being used. It is still a great measure of how laggy somebody is. Less than 100 is very good, over 500 is bad, and over 1000 microseconds is horrible.
OBJECT SCRIPT TIME - Second Life Wiki

===REGION NUMBERS===
**FPS**
This tells you how many Frames Per Second (FPS) the sim is running at. When lag picks up the sim runs at lower FPS. FPS is never greater than 45. The lower this number the laggier things get.
LSL Wiki : llGetRegionFPS

**Dilation**
When sims get laggy they run slower, which makes time slow down. When time dilation is lowit feels like you are trying to walk through quicksand when you try to walk. If time dilation is 1 then there is no time dilation effect on the sim, which means no serious lag. When time dilation gets smaller the lag increases. When it hits zero the sim is about to crash.
LSL Wiki : llGetRegionTimeDilation

**Agents**
This is how many avatars are in the sim. More avatars create more lag.

**Prims**
In this HUD, prims refers to how many free prims are available in the entire region. The less prims a region has available the more lag it will have.

**Temp**
Temporary prims are prims that only exist for a short period of time and then disappear. They do not contribute to the region's prim count. Usually temporary prims do not contribute to lag very much, but some devices make extensive use of them and that creates a lot of lag.
LSL Wiki : TemporaryOnRez


===COLORS===
The colors in the HUD tell you at a glance how bad an avatar or region's lag is.

**Avatar Colors**
White: Memory is less than 2 Mb
Green: Memory is between 2 and 6 Mb
Yellow: Memory is between 6 and 12 Mb
Red: Memory is over 12 Mb

**Region Colors**
White: Time dilation is greater than 0.9
Green: Time dilation is between 0.75 and 0.9
Yellow: Time dilation is between 0.5 and 0.75
Red: Time dilation is lower than 0.5

Last edited by bubblesort; 11-10-2011 at 01:11 PM.
bubblesort is offline   Reply With Quote
1 User Said Yay!:
Old 11-10-2011, 01:05 PM   #2 (permalink)
Banned
 
Join Date: Mar 2011
Location: Pennsylvania
Posts: 1,213
SL Join Date: Jan 2007
This is part 1 of the code:

Code:
//General notes:
//see this web page for more info on URI namespace:
//see http://wiki.secondlife.com/wiki/Viewer_URI_Name_Space

//Debug notes:
//need to find non-group owned land to test this out on

//GLOBALS
list region;    //list of useful information about a region
list keyList;   //list of avatar keys detected by the radar

//constants
float refresh = 2;      //sensor refresh rate

//bitmasks
integer AGENT_PROFILE = 100;
integer AGENT_IM = 150;
integer GROUP_PROFILE = 200;
integer LOCATION_PROFILE = 300;

//for determining color
integer DILATION = 10;
integer SCRIPT_TIME = 20;
integer MEMORY = 30;
list tolerances = [0.9, 0.75, 0.5,          //time dilation
                    100, 500, 1000,         //script time (milliseconds)
                    2, 6, 12];              //memory

//Load the region information
LoadRegion(){
    llOwnerSay("Fetching region information...");
    region = GetRegionInfo(FALSE, llGetRegionName(), llGetPos());
    llOwnerSay("Ready!");
}

//send the information to the appropriate function, depending on whether
//we want the color set regarding time dilation, script memory or script
//time.  This is set by metric == DILATION, MEMORY or SCRIPT_TIME
vector ColorVector(integer metric, float number){
    vector color;
    
    //if set by time dilation, high numbers are better than low numbers
    if(metric == DILATION){
        color = ColorHighToLow(DILATION, number);
    }
    
    //if set by memory or script time low numbers are better than high numbers
    else if((metric == MEMORY) || (metric == SCRIPT_TIME)){
        color = ColorLowToHigh(metric, number);
    }
    
    return color;
}

//return the appropriate color vector based on the tolerances list, where
//high numbers are better than low numbers.
vector ColorHighToLow(integer metric, float number){
    vector shade;
    integer offset;
    
    //offset tells us where to start reading the tolerances list
    if(metric == DILATION){
        offset = 0;
    }
    
    //set shade to appropriate color
    if(number>llList2Float(tolerances,offset)){
        shade = <1.0,1.0,1.0>;              //white
    }
    else if(number>llList2Float(tolerances,offset+1)){
        shade = <0.0,1.0,0.0>;              //green
    }
    else if(number>llList2Float(tolerances,offset+2)){
        shade = <1.0,1.0,0.0>;              //yellow
    }
    else if(number<llList2Float(tolerances,offset+2)){
        shade = <1.0,0.0,0.0>;              //red
    }
    else{
        shade = <0.6, 0.0, 0.6>;            //purple
    }
    return shade;
}

//return the appropriate color vector based on the tolerances list, where
//high numbers are better than low numbers.
vector ColorLowToHigh(integer metric, float number){
    vector shade;
    integer offset;
    
    //offset tells us where to start reading the tolerances list
    if(metric == SCRIPT_TIME){
        offset = 3;
    }
    else if(metric == MEMORY){
        offset = 6;
    }
    
    //set shade to appropriate color
    if(number < llList2Float(tolerances,offset)){
        shade = <1.0,1.0,1.0>;              //white
    }
    else if(number < llList2Float(tolerances,offset+1)){
        shade = <0.0,1.0,0.0>;              //green
    }
    else if(number < llList2Float(tolerances,offset+2)){
        shade = <1.0,1.0,0.0>;              //yellow
    }
    else if(number >= llList2Float(tolerances,offset+2)){
        shade = <1.0,0.0,0.0>;              //red
    }
    else{
        shade = <0.6, 0.0, 0.6>;            //purple
    }

    return shade;
}

//takes location name and vector and returns a list of region info with the following schema:
//index 0:  Name of region
//index 1:  URL of region using URI namespace
//index 2:  Region host
//index 3:  Region channel
//index 4:  Region version
//index 5:  Region FPS
//index 6:  Region time dilation
//index 7:  Region agent count
//index 8:  Region max prims
//index 9:  Region prim count
//index 10:  Region available prims
//index 11:  Region group and owner owned prims
//index 12:  Region temp prim count
list GetRegionInfo(integer radar, string regionName, vector regionPos){
    list regionInfo;
    
    if(radar == FALSE){
        regionInfo = [regionName, 
            GetURL(LOCATION_PROFILE, NULL_KEY, regionName, regionPos), 
            llGetSimulatorHostname(), 
            llGetEnv("sim_channel"), 
            llGetEnv("sim_version")];
        regionInfo += [llGetRegionFPS(),                //FPS
            llGetRegionTimeDilation(),                  //Time Dilation
            llGetRegionAgentCount(),                    //Agent Count
            llGetParcelMaxPrims(regionPos, TRUE),       //Max Prims
            llGetParcelPrimCount(regionPos, PARCEL_COUNT_TOTAL, TRUE),                                                                  //Prim Count
            llGetParcelMaxPrims(regionPos, TRUE) - llGetParcelPrimCount(regionPos, PARCEL_COUNT_TOTAL, TRUE),                            //Available Prims
            llGetParcelPrimCount(regionPos, PARCEL_COUNT_GROUP, TRUE) +  llGetParcelPrimCount(regionPos, PARCEL_COUNT_OWNER, TRUE),    //Group and Owner Owned Prims
            llGetParcelPrimCount(regionPos, PARCEL_COUNT_TEMP, TRUE)];                                                                  //Temp Prims
    }

//schema:
//index 0:  region name
//index 1:  FPS
//index 2:  time dilation
//index 3:  agent count
//index 4:  prims available
//index 5:  temp prim count
//index 6:  color vector
    else if(radar == TRUE){
        string dilation = llGetSubString((string)llGetRegionTimeDilation(), 0, 3);
        
        regionInfo = [regionName];
        regionInfo += [(integer)llGetRegionFPS(), 
            dilation,
            llGetRegionAgentCount(),
            llGetParcelMaxPrims(regionPos, TRUE) - llGetParcelPrimCount(regionPos, PARCEL_COUNT_TOTAL, TRUE),
            llGetParcelPrimCount(regionPos, PARCEL_COUNT_TEMP, TRUE),
            ColorVector(DILATION, llGetRegionTimeDilation())];
    }
    return regionInfo;
}
    
//Get information about the parcel and resource usage
//Takes location vector and returns a list of information with the following schema:
//index 0:  parcel name
//index 1:  parcel area
//index 2:  Parcel owner
//index 3:  Parcel group
//index 4:  group owned?  TRUE or FALSE
//index 5:  parcel max prims
//index 6:  parcel prim count
//index 7:  parcel available prims
//index 8:  parcel group and owner owned prims
//index 9:  parcel temp prim count
list GetParcelInfo(vector parcelPos){
    list parcelInfo = llGetParcelDetails(parcelPos, [PARCEL_DETAILS_NAME,
        PARCEL_DETAILS_AREA,
        PARCEL_DETAILS_OWNER,
        PARCEL_DETAILS_GROUP]);
    //determine if land is group owned or not and add that info to the list
    if(llKey2Name(llList2String(parcelInfo,2)) == ""){
        parcelInfo += TRUE;
    } else {
        parcelInfo += FALSE;
    }
    
    //add resource usage information to parcelDetails
    
    parcelInfo += [llGetParcelMaxPrims(parcelPos, FALSE),                                                                        //max prims
        llGetParcelPrimCount(parcelPos, PARCEL_COUNT_TOTAL, FALSE),                                                                 //prim count
        llGetParcelMaxPrims(parcelPos, FALSE) - llGetParcelPrimCount(parcelPos, PARCEL_COUNT_TOTAL, FALSE),                         //available prims
        llGetParcelPrimCount(parcelPos, PARCEL_COUNT_GROUP, FALSE) +  llGetParcelPrimCount(parcelPos, PARCEL_COUNT_OWNER, FALSE),  //group and owner owned prims
        llGetParcelPrimCount(parcelPos, PARCEL_COUNT_TEMP, FALSE)];                                                                 //temp prims
    
    return parcelInfo;
}
bubblesort is offline   Reply With Quote
Old 11-10-2011, 01:06 PM   #3 (permalink)
Banned
 
Join Date: Mar 2011
Location: Pennsylvania
Posts: 1,213
SL Join Date: Jan 2007
This is part 2 of the code:

Code:
//The first argument, radar, tells us if the request is from the radar or from something else.
//If the request is not from the radar then it gets less information than if the request is from 
//a region change or a touch.
                    
//If request for agent information is not for the radar then take agent position and agent key and return a list of agent information with the following schema:
//index 0:  Profile URL
//index 1:  Username
//index 2:  Display Name
//index 3:  Running Script Count
//index 4:  Total Script Count
//index 5:  Memory
//index 6:  Script Time
//index 7:  Prim Equivalence
//index 8:  IM URL

//If request for agent information is for the radar then take agent position and agent key and return a list of agent information with the following schema:
//index 0:  Position
//index 1:  Username
//index 2:  Display Name
//index 3:  Total Script Count
//index 4:  Memory
//index 5:  Script Time
//index 6:  UUID
//index 7:  color vector
list GetAgentInfo(integer radar, vector agentPos, key agentKey){
    list agentInfo;

    if(radar == TRUE){
        agentInfo = [agentPos, 
            llGetUsername(agentKey), 
            llGetDisplayName(agentKey)];
        
        agentInfo += llGetObjectDetails(agentKey, 
            [OBJECT_TOTAL_SCRIPT_COUNT,
            OBJECT_SCRIPT_MEMORY,
            OBJECT_SCRIPT_TIME]);
            
        agentInfo += agentKey;
        
        integer memory = llList2Integer(agentInfo,4);
        memory /= 1000000;
        agentInfo += ColorVector(MEMORY, (float)memory);
    }
    else if(radar == FALSE){
        agentInfo = [GetURL(AGENT_PROFILE, agentKey, "", ZERO_VECTOR), 
            llGetUsername(agentKey), 
            llGetDisplayName(agentKey)];
        
        agentInfo += llGetObjectDetails(agentKey, 
            [OBJECT_RUNNING_SCRIPT_COUNT, 
            OBJECT_TOTAL_SCRIPT_COUNT,
            OBJECT_SCRIPT_MEMORY,
            OBJECT_SCRIPT_TIME,
            OBJECT_PRIM_EQUIVALENCE]);
        
        agentInfo += GetURL(AGENT_IM, agentKey, "", ZERO_VECTOR);
    }
    return agentInfo;
}

//takes the region information and returns the region output string
string BuildRegionOutput(integer radar, list simData){
    string regionOutput;
    
    if(radar == FALSE){
        regionOutput = "Region: " + llList2String(simData,0) +
            "\n" + llList2String(simData,1) + 
            "\nHost: " + llList2String(simData,2) + 
            "\n" + llList2String(simData,3) + " v" + llList2String(simData,4) + 
            "\n\nFPS: " + llList2String(simData,5) +
            "\nTime Dilation: " + llList2String(simData,6) + 
            "\nAgents: " + llList2String(simData,7) +
            "\n\n==REGION PRIM USAGE==" +
            "\nAvailable Prims: " + llList2String(simData,10) +
            "\nMax Prims: " + llList2String(simData,8) + 
            "\nPrims Used: " + llList2String(simData,9) +          
            "\nPrims Set To Land Owner: " + llList2String(simData,11) + 
            "\nTemp Prims: " + llList2String(simData,12);
    }

    else if(radar == TRUE){
        regionOutput = llList2String(simData,0) + 
            "|FPS:" + llList2String(simData,1) + 
            "|Dilation:" + llList2String(simData,2) + 
            "\n| |agents:" + llList2String(simData,3) + 
            "| |prims:" + llList2String(simData,4) +
            "| |temp:" + llList2String(simData,5);
    }
    return regionOutput;
}

//takes the parcel information and returns the parcel output string
string BuildParcelOutput(list parcelData){

    //this will store the land owner information    
    string landOwner;
            
    //if land is group owned get the group profile URL
    if(llList2Integer(parcelData,4) == TRUE){
        landOwner = GetURL(GROUP_PROFILE, llList2String(parcelData,3), "", ZERO_VECTOR);
    } 
    
    //if land is not group owned get the owner's profile URL        
    else {        
        landOwner = GetURL(AGENT_PROFILE, llList2String(parcelData,3), "", ZERO_VECTOR);
    }

    //build the string with the parcel information to be output
    string parcelOutput = "Parcel: " + llList2String(parcelData,0) + 
        "\nSize: " + llList2String(parcelData,1) +
        "\nOwned By: " + landOwner +
        "\n\n==PARCEL PRIM USAGE==" + 
        "\nAvailable Prims: " + llList2String(parcelData,7) +
        "\nMax Prims: " + llList2String(parcelData,5) +
        "\nPrims Used: " + llList2String(parcelData,6) +
        "\nPrims Set To Land Owner: " + llList2String(parcelData,8) +
        "\nTemp Prims: " + llList2String(parcelData,9);            
            
    //return the string with the parcel information to be output
    return parcelOutput;
}
            
string BuildAgentOutput(integer radar, list agentData){
    string agentOutput;
    
    //if this is for the radar
    if(radar == TRUE){
        agentOutput = llList2String(agentData,2) + " (" + llList2String(agentData,1) + ") " +
            (string)llAbs(llRound(llVecDist(llGetPos(), llList2Vector(agentData,0)))) + "m\n|" + 
            llList2String(agentData, 3) + "scripts| |" +
            (string)(llRound(llList2Float(agentData,4) / 1000000)) + "Mb| |" +
            (string)(llRound(llList2Float(agentData, 5)*1000000)) + "MicroSec|";
    }
    
    //if this is not for the radar
    else if(radar == FALSE){
        agentOutput = llList2String(agentData,2) + " (" + llList2String(agentData,1) + ")" +
            "\nProfile Link: " + llList2String(agentData,0) +
            "\nIM Link: " + llList2String(agentData,8) + 
            "\nTotal Script Count: " + llList2String(agentData,4) +
            "\nRunning Script Count: " + llList2String(agentData,3) + 
            "\nScript Memory Allocated: " + (string)(llList2Integer(agentData,5) / 1000) + " Kb" +
            "\nScript Time: " + (string)(llRound(llList2Float(agentData, 6)*1000000)) + " MicroSec" + 
            "\nPrim Equivalence: " + llList2String(agentData,7);
    }
    return agentOutput;
}

//takes information and returns a URL using URI namespace
string GetURL(integer type, key UUID, string name, vector locationPos){
    //if we want a location profile link then
    if(type == LOCATION_PROFILE){
        //break the location vector into numbers
        integer posX = (integer)locationPos.x;
        integer posY = (integer)locationPos.y;
        integer posZ = (integer)locationPos.z;
        
        //use the location vector numbers to create the location URL
        string locString = "secondlife://" + llEscapeURL(name) + "/" 
            + (string)posX + "/" + (string)posY + "/" + (string)posZ;
        return locString;
    }
    //if we want a group profile link then
    else if(type == GROUP_PROFILE){
        return "secondlife:///app/group/" + (string)UUID + "/about";
    }
    //if we want an agent profile link then
    else if(type == AGENT_PROFILE){
        return "secondlife:///app/agent/" + (string)UUID + "/about";
    }
    //if we want the IM URL for an agent then
    else if(type == AGENT_IM){
        return "secondlife:///app/agent/" + (string)UUID + "/im";
    }    
    //if we get garbage in then
    else{
        return "garbage in garbage out";
    }
}
bubblesort is offline   Reply With Quote
Old 11-10-2011, 01:07 PM   #4 (permalink)
Banned
 
Join Date: Mar 2011
Location: Pennsylvania
Posts: 1,213
SL Join Date: Jan 2007
This is part 3 of the code:

Code:
default
{
    on_rez(integer num){
        llResetScript();
    }
    
    state_entry(){
        //so it will run in no script areas
        llRequestPermissions(llGetOwner( ), PERMISSION_TAKE_CONTROLS);
        //get region info (this takes a few seconds because of throttling)
        LoadRegion();
        //start the radar
        llSensorRepeat("", "", AGENT,96, PI, refresh);
    }

    touch_start(integer total_number){
        //if the region name was touched get and output the region information
        if(llDetectedLinkNumber(0) == 2){
            list parcel = GetParcelInfo(llGetPos());
            llOwnerSay("\n" + BuildRegionOutput(FALSE, region) + "\n\n" + BuildParcelOutput(parcel) + "\n");
        }
        
        //if an agent name was touched get the agent information
        else if(llDetectedLinkNumber(0) > 2 && llDetectedLinkNumber(0) < 15){
            list target = GetAgentInfo(FALSE, ZERO_VECTOR, llList2Key(keyList,llDetectedLinkNumber(0)-3));
            
            //output agent information only if the agent exists
            if(llList2String(target,1) != ""){
                llOwnerSay(BuildAgentOutput(FALSE, target));
            }
        }
    }
        
    sensor(integer num_detected){
        //get the region information and put it in the list 'sim'
        list sim = GetRegionInfo(TRUE, llGetRegionName(), llGetPos());
        
        //format the region information into the list 'radarList' and start a list of colors for the float text, 
        //starting with the color of the region info text
        list radarList = [BuildRegionOutput(TRUE, sim)];
        list colorList = [llList2Vector(sim,6)];
        
        //get owner's information and add the owner's information to the list of things to be displayed on the radar
        list me = GetAgentInfo(TRUE, llGetPos(), llGetOwner());
        radarList += BuildAgentOutput(TRUE, me);
        
        //add owner's key to the key list, which is used for the touch event
        keyList = [llList2Key(me,6)];
        
        //add owner's float text color to the color list
        colorList += llList2Vector(me,7);
        
        //build list of agent information to display.
        //there are 12 prims left to populate with information after we use the first two to 
        //display the sim and owner information.
        integer count;
        for(count=0; count<12; count++){
            //if agent number count is detected then
            if(count<num_detected){
                //save their information temporarily in the agentRadar list then pass it to the 
                //keyList, colorList and radarList.  The agentRadar list will destruct on each
                //iteration.
                list agentRadar = GetAgentInfo(TRUE, llDetectedPos(count), llDetectedKey(count));
                keyList += llList2Key(agentRadar,6);
                colorList += llList2Vector(agentRadar,7);
                radarList += BuildAgentOutput(TRUE, agentRadar);
        
            //if agent number count is not detected then put a blank string in radarList
            } else {
                radarList += "";
            }
        }
        
        //display list of strings using set link params fast to display the information as float text
        //on each prim in the HUD.
        for(count=0; count<14; count++){
            llSetLinkPrimitiveParamsFast(count+1, [PRIM_TEXT, llList2String(radarList,count), llList2Vector(colorList,count), 1.0]);
        }
    }
    
    //if there are no agents around we still want to display the region and owner's information.
    no_sensor(){
        //get region information, save it to the list 'sim' and pass 'sim' to the build region output
        //function to format it properly, saving the output to the 'radarList' list and the color to
        //the colorList list
        list sim = GetRegionInfo(TRUE, llGetRegionName(), llGetPos());
        list radarList = [BuildRegionOutput(TRUE, sim)];
        list colorList = [llList2Vector(sim,6)];
        //llOwnerSay((string)llList2Vector(sim,6));
        
        //get owner's information, save it to the list 'me' then pass 'me' to the build agent output
        //function and save the output results to the list 'radarList'.
        list me = GetAgentInfo(TRUE, llGetPos(), llGetOwner());
        radarList += [BuildAgentOutput(TRUE, me)];
        
        //add owner's key to the keyList list for the touch event and add their color to the colorList
        //for the float text.
        keyList = [llList2Key(me,6)];
        colorList += llList2Vector(me,7);
        
        //display the region and owner information on prims 1 and 2 and display an empty string on the rest
        //of the 14 prims.
        integer count;
        for(count=0; count<=14; count++){
            if(count<=2){
                llSetLinkPrimitiveParamsFast(count+1, [PRIM_TEXT, llList2String(radarList,count), llList2Vector(colorList,count), 1.0]);
            } else {
                llSetLinkPrimitiveParamsFast(count, [PRIM_TEXT, "", <1,1,1>, 1.0]);
            }
        }
    }
    
    //reload region info on region change
    changed(integer change){
        if(change & (CHANGED_REGION | CHANGED_TELEPORT)){
            LoadRegion();
        }
    }
    
    //so it will run in no script areas
    run_time_permissions(integer perms)
    {
        llTakeControls(CONTROL_FWD, 0, 1);
    }
}
bubblesort is offline   Reply With Quote
Old 11-10-2011, 01:56 PM   #5 (permalink)
Senior Member
 
Voodoo Radek's Avatar
Look behind you!
 
Join Date: Oct 2011
Posts: 113
SL Join Date: 13/08/07
Business: Capsule Tech.
Thanks for share bubblesort!

__________________

Voodoo Radek is offline   Reply With Quote
Old 11-10-2011, 08:01 PM   #6 (permalink)
Senior Member

*SLU Supporter*
 
Darien Caldwell's Avatar
LLvangelist
 
Join Date: Apr 2008
Location: Cali
Posts: 3,890
My Mood:
SL Join Date: 10/12/2006
Business: [H]arsh Styles
Client: Always changing, and too lazy to edit.
The only problem I have is the arbitrary designation of X mb of memory = Y. It's really a lot more complicated than that to discern someong as being 'laggy' or not.

You could have 4 people in a sim with 20 megs of scripts on each, and it's not going to cause a single bit of lag. If you had 40 people doing that, it's a whole other story. And really the script time (how active the scripts are) is a larger measure of how much lag is being caused, not how much memory is used.

Memory only factors into lag when a sim's allocated memory becomes full, and it has to start swapping memory to disk. Before that, it's not a factor at all.

So to go back to your script, A more accurate measure of lag would be to add up the memory of all scripts for all avatars in the sim, and subtract that from the available sim memory pool size. If there is sitll memory in the pool, their lag is negligble, no matter what the memory size is.

If the pool is depleted, then they could be rated on a sliding scale from largest memory consumer to lowest.

The problem is determining how big the sim's pool is, as many other things use sim memory too, prims, physics representations, etc, etc.
__________________
[H]arsh Styles

The truth doesn't care if you agree with it or disagree with it. It continues to be regardless, unchanged. Denying the truth is only lying to yourself. - Darien Caldwell
Darien Caldwell is offline   Reply With Quote
1 User Said Thanks:
Old 11-10-2011, 08:02 PM   #7 (permalink)
Senior Member
 
KT Kingsley's Avatar
Praying for intelligent life somewhere up in space, 'cause there's bugger all down here on Earth
 
Join Date: Jul 2011
Location: UK
Posts: 3,675
I think you need a control () {} event handler (albeit an empty one) for the anti-no script to work.
KT Kingsley is offline   Reply With Quote
Old 11-10-2011, 08:14 PM   #8 (permalink)
Senior Member

*SLU Supporter*
 
Eunoli Rain's Avatar
In need of a new avatar
 
Join Date: Mar 2011
Posts: 3,115
How much does this script itself take in resources?
Eunoli Rain is offline   Reply With Quote
1 User Laughed:
Old 11-11-2011, 03:07 AM   #9 (permalink)
Banned
 
Join Date: Mar 2011
Location: Pennsylvania
Posts: 1,213
SL Join Date: Jan 2007
@Darien: That would be a great way to measure the impact of script memory! I'm not sure how to get total memory available in a region, but I'll look into it. Maybe I'll try to find out at an office hour or something.

To be honest, I think script time is probably the best way to measure lag, but I saw a board at fur nation that measures lag with script memory, so I went with that for now since that seems to be the standard way people are doing it. I didn't care much about if memory is the best way to do it or not for version 1.0 because I was hoping to start a conversation like this on what the best way to do it is.

I'm thinking in the next version I'll put a dialog box setup in the root prim so you can click it and set what metric controls the text color and what constitutes high medium and low lag. I just want to get some reactions on what metrics are important before I do that.

Your idea got me thinking that maybe I should put number of used and available URLs in the verbose region info for when you click the region name.

@KT: It works fine in no script areas as it is.

@Eunoli: This script is pretty light. I know, you see all these prims and text and think the script count must be through the roof, but it uses link messages to set that text, so it's all one script. I had to chop it up into 3 sections to fit it into a thread here, but it's all one script.

When I have nothing but the lag radar on this is the information I get by clicking my own name:

Total Script Count: 1
Running Script Count: 1
Script Memory Allocated: 65 Kb
Script Time: 8 MicroSec
Prim Equivalence: 1

To put that in perspective, when I wear the lag radar plus the classic flight feather made by Argent Stonecutter I get this:

Total Script Count: 2
Running Script Count: 2
Script Memory Allocated: 81 Kb
Script Time: 18 MicroSec
Prim Equivalence: 1

An opencollar AO worn with this HUD and nothing else gives these results:

Total Script Count: 7
Running Script Count: 7
Script Memory Allocated: 458 Kb
Script Time: 162 MicroSec
Prim Equivalence: 1

If you have any ideas on how to optimize this just let me know or post some code. I'm still actively developing this.

EDIT:

I'd like to add that there is an art to using this HUD for sim management. I built it because I run a busy sandbox and clicking the script time tool takes forever. With this I can see how heavy the scripts are in the agents around me. I can also use this to get people to cut back on scripts without upsetting them. Sim management is an art, not a science. Booting people for wearing too many scripts is a recipe for dramatics. This is how you use this HUD to cut back on lag in your region with as little trouble as possible:

1. Identify who is too laggy.
2. IM them and ask them if they think the region is too laggy. Ask them if they think you should restart the region or not.
3. Act like you just noticed on the HUD that they have a lot of scripts on. Give them a copy of the lag radar HUD to show them. People love free stuff.
4. At this point they usually go 'OMG, I'm so sorry!' and take a few attachments off. A lot of the time the lag is coming from their hair. Women seem to be more laggy than men because of this, I think.
5. ???
6. PROFIT!!!

Last edited by bubblesort; 11-11-2011 at 03:16 AM.
bubblesort is offline   Reply With Quote
Old 11-11-2011, 03:16 AM   #10 (permalink)
The Purple
 
Chalice Yao's Avatar
HEYOO!
 
Join Date: Dec 2007
Location: Somewhere purple, Germany
Posts: 8,127
My Mood:
SL Join Date: 20. January 2007
Client: NaCl
My suggestion is to divide the microseconds an avatar script set uses up by 1000.0

From the ctrl+shift+1 display in the client, and the estate tools, people are used to see the usage of objects and avatars in milliseconds, not microseconds..so, 250 -> 0.250ms etc.

And I have to agree with Darien that how much memory an avatar or script -can- take up isn't the best way to measure lag, albeit it can show how much memory in total the avatars in a sim can take up..that can be very helpful. Amount of scripts identifies badly coded items or overstuffed avatars much better, as well as the aformentioned script time, which is probably the best lag checker.

Personally I consider any avatar whose scripts have allocated over 2 MB quite bad, tho I agree roughly with your script time judgements. Below 0.1ms is great, below 0.25ms is okay, over that is getting into territory where I'd say 'See if you can fix this'. Mind you, when sim performance drops, the ms of scripts can actually go up as things take longer.
__________________
"Have you ever noticed that anybody driving slower than you is an idiot, and anyone going faster than you is a maniac?" - George Carlin
Chalice Yao is offline   Reply With Quote
1 User Said Thanks:
Old 11-11-2011, 05:36 AM   #11 (permalink)
Banned
 
Join Date: Mar 2011
Location: Pennsylvania
Posts: 1,213
SL Join Date: Jan 2007
Thanks for the milli-to-microseconds tip. I had it that way to begin with but it just looked kind of cluttered in the HUD. A couple of characters for the '0.' might seem small but if you put it in float text in a HUD it makes a big difference. If that change is noticeable, though, then it needs to be displayed in milliseconds, because it's more important that people understand what is happening than it is for it to look pretty.

As far as memory goes, remember that memory is a direct function of script count, since each script is automatically allocated 64k for mono scripts and 16k for LSO scripts. That means that memory is just as useful as script count for tracking laginess. Script count is just easier to read at a glance. Memory just kind of shows what script count means in a more concrete way. Script time shows how actively the scripts are using resources, so I think that's what's really important.

As far as balancing memory and script time, I'm thinking both are important, but which one should be used to measure lag depends on the region's situation. We can use script time to measure laginess until the sim performance starts seriously degrading then flip over to using memory to measure lag because when performance degrades it means the server is paging between physical and virtual memory.

When using memory it would be useful to use a ratio of an agent's total script memory usage to the available script memory used in the region. If I'm using 6Mb and the region has 500 Mb available then my ratio would be 0.012, so I'm using 1.2% of total available resources.

It would be ideal to calculate total memory used and total memory available in a region, but I doubt that we have access to that information with scripts. If we can get a general idea of how much memory a region has available that would be useful, but with multiple regions hosted on each server that might be a problem. I'm pulling numbers out of thin air here, but if we have 8 sims on a server and each server has 12 gigs of memory then each region might have 666 Mb if it's load balanced perfectly, but they probably have ways of giving one region more resources when it's needed.

Worst case scenario, if we don't know how much memory a region has then I'm thinking we can use FPS and Time Dilation to measure region performance so we know when to flip to measuring memory. Where should that threshold be? I know if my sim starts dipping below 0.5 time dilation or if it's constantly below 0.8 time dilation I start looking for the problem.

I'm going to bring this up today at the Simulator User Group meeting at 4:00 SLT. It's held in Denby.

A quick search on Google shows that Becky Pippin has done some research into these issues. On her wiki talk page she says this:

Quote:
In the 95% of the regions that run smoothly, the simulator uses less than 800MB of RAM for everything except scripts, and up to 300MB for all the scripts in the region, and that's ok. In the worst 5% of the regions, simulators use up to 2GB of RAM on the server, and that's not ok.
That's not much and the information is probably old, but it's a starting point for now.
bubblesort is offline   Reply With Quote
Old 11-11-2011, 07:11 AM   #12 (permalink)
The Purple
 
Chalice Yao's Avatar
HEYOO!
 
Join Date: Dec 2007
Location: Somewhere purple, Germany
Posts: 8,127
My Mood:
SL Join Date: 20. January 2007
Client: NaCl
Quote:
Originally Posted by bubblesort View Post
As far as memory goes, remember that memory is a direct function of script count, since each script is automatically allocated 64k for mono scripts and 16k for LSO scripts.
There is, to my knowledge, an important difference between the two. The 16kb LSO is reserved for that script, period. Nothing else can use that memory..it's basically immediately all used up in ram. In the case of MONO scripts, those 64kb are simply a set limit, and not literally reserved, unusable-by-anything-else memory. Sadly they will not update the displays to show what a script is actually using in the MONO case, as that'd supposedly be too slow and resource intensive.


Quote:
When using memory it would be useful to use a ratio of an agent's total script memory usage to the available script memory used in the region.
AFAIK a normal region has 200-300mb of memory for scripts, before it starts swapping. So a region with 50 avatars using 2 MB each would be using up 100mb, leaving the other half for the land..hence my 'below 2 MB guideline'. Theoretically you could TP anywhere without being the cause of a memory shortage per se.

Quote:
A quick search on Google shows that Becky Pippin has done some research into these issues. On her wiki talk page
Yeah, that was Babbage's old Memory Limit work. I wish LL had implemented those, but alas..it's shelved. Not gone, but won't be happening soon, I fear.
Chalice Yao is offline   Reply With Quote
1 User Said Thanks:
Old 11-11-2011, 09:01 AM   #13 (permalink)
Nasty Brit
 
Innula Zenovka's Avatar
Grande Cabalista
 
Join Date: May 2009
Posts: 11,278
SL Join Date: 17 June 2007
Business: Something Spunky
Quote:
Originally Posted by KT Kingsley View Post
I think you need a control () {} event handler (albeit an empty one) for the anti-no script to work.
You've certainly got to call llTakeControls in the run_time_permissions event for the trick to work (i.e., simply requesting PERMISSION_TAKE_CONTROLS is insufficient on its own), but I've never bothered to put in an unnecessary control event, and it always works for me.
Innula Zenovka is offline   Reply With Quote
Old 11-11-2011, 11:37 AM   #14 (permalink)
Senior Member
Invisible
 
Join Date: Sep 2010
Posts: 2,235
Quote:
Originally Posted by bubblesort View Post
EDIT:

I'd like to add that there is an art to using this HUD for sim management. I built it because I run a busy sandbox and clicking the script time tool takes forever. With this I can see how heavy the scripts are in the agents around me. I can also use this to get people to cut back on scripts without upsetting them. Sim management is an art, not a science. Booting people for wearing too many scripts is a recipe for dramatics. This is how you use this HUD to cut back on lag in your region with as little trouble as possible:

1. Identify who is too laggy.
2. IM them and ask them if they think the region is too laggy. Ask them if they think you should restart the region or not.
3. Act like you just noticed on the HUD that they have a lot of scripts on. Give them a copy of the lag radar HUD to show them. People love free stuff.
4. At this point they usually go 'OMG, I'm so sorry!' and take a few attachments off. A lot of the time the lag is coming from their hair. Women seem to be more laggy than men because of this, I think.
5. ???
6. PROFIT!!!
It's one thing if you're a landowner or an admin. It's another if you're a visitor and you start IMing people, "according to my HUD you're wearing too many scripts and lagging the sim". The response is not going to be pretty. Therefore I would market this strictly as an admin tool and not as a policing tool. I know it's hard to do when you have it up on the MP for anyone to buy, but I would suggest a disclaimer as such.
__________________
Quote:
Originally Posted by Andrea Mitchell
[pause] Sorry. I'm just trying to catch my breath after that last comment.
Darik is offline   Reply With Quote
Old 11-11-2011, 01:03 PM   #15 (permalink)
Provincial Sharia-slun
 
Casey Pelous's Avatar
Jesus is coming. Look busy!
 
Join Date: Feb 2011
Location: USA
Posts: 6,823
My Mood:
SL Join Date: August 21, 2007
Client: Anything But 2
Quote:
Originally Posted by Darik View Post
It's one thing if you're a landowner or an admin. It's another if you're a visitor and you start IMing people, "according to my HUD you're wearing too many scripts and lagging the sim". The response is not going to be pretty. Therefore I would market this strictly as an admin tool and not as a policing tool. I know it's hard to do when you have it up on the MP for anyone to buy, but I would suggest a disclaimer as such.
Good point, but someone that socially obtuse really doesn't require a scripted object to create non-pretty responses!
__________________
"I am not more than a lossy Human being, and think that we all are equals..." - Wasted Engineer


U.S. Only
Casey Pelous is offline   Reply With Quote
1 User Laughed:
Old 11-11-2011, 01:23 PM   #16 (permalink)
Senior Member
Invisible
 
Join Date: Sep 2010
Posts: 2,235
Quote:
Originally Posted by Casey Pelous View Post
Good point, but someone that socially obtuse really doesn't require a scripted object to create non-pretty responses!
No, but why give them the ammo?
Darik is offline   Reply With Quote
Old 11-11-2011, 01:47 PM   #17 (permalink)
Senior Member

*SLU Supporter*
 
Eunoli Rain's Avatar
In need of a new avatar
 
Join Date: Mar 2011
Posts: 3,115
If you're marketing it as an admin tool, what do they get that Estate Manager won't give them? I'm kind of missing that. When my sim lags and I see that agent time is the bottleneck in the statistics bar I can go to top scripts and almost instantly get the same information without a hud, can't I? Or am I missing something?
Eunoli Rain is offline   Reply With Quote
Old 11-11-2011, 02:33 PM   #18 (permalink)
Banned
 
Join Date: Mar 2011
Location: Pennsylvania
Posts: 1,213
SL Join Date: Jan 2007
I like Darik's idea of putting a notice in the marketplace listing telling people not to be idiots with this. I really don't have the authority to tell people what to do with it, I can just suggest uses for it. JLU type ass hats are always going to find reasons to mess with people, whether it's with this HUD or whether it's with average rendering cost.

@Eunoli: The estate manager scripts window is always very laggy for me, especially when I need it most. It's a great tool, and I need it to see people farther than 96m away because I didn't build a full sim scanner into this, but this is just faster. It also lets me see if somebody nearby happens to be too overloaded.

I'm hoping that this HUD can be used to make script resources more concrete for people. Most really laggy people don't know they're really laggy, and when they see how laggy they are on this HUD, in my experience, they tend to try to fix the problem. People want to have less lag, they just lack the information to do anything about it. I'm hoping that this open source project might be able to help fix that problem, to a certain degree. This HUD lets people see their own lag and compare it to the lag created by others so they can tell if they really are worse than other people or not when it comes to script resource usage. I think that's really the most important job it does.

I guess that means I'm not really intending this to be used exclusively for sim management. I was just saying that I do use it for sim management and this is how I do it without causing problems. Ultimately, what I intend people to do with it doesn't really matter, though.

@Chalice:

IDK about the 2Mb being too much for an agent to use. My fancy Vista AO puts me 622Kb, which is more than a quarter of the way to the 2Mb point. When I'm wearing xcite genitals, my AO and lightly scripted shoes I'm at 10Mb and 200 microseconds. I personally don't walk around like that but I think it's not an uncommon thing for people to walk around wearing these kinds of things. The script count in these things is high, but the script activity is low, and as you noted there is no way to tell how much memory is actually being used by the scripts. Because of that, I'm thinking that script time is better for measuring resource usage.

When I set tolerances for what constitutes high, medium and low resource usage I'm looking at what the average SL user might be doing. The HUD should show people where they fit along the continuum of too laggy to no lag at all, in comparison to others. It's not supposed to make everybody look like they're trying to crash the sim. Walking around SL with this HUD on gave me some insight into what kind of script usage the average SL user uses, but I don't actually have hard numbers on this yet.

I'm considering doing some statistical analysis on how much resources people generally use, but I need to set up some kind of database for that. I'm thinking about using some HTTP commands to feed memory, script time, FPS and dilation information to a database script every now and then as I wander around SL. I could just send a list of memory, script count and script time to the server every 5 mins. No need to record names with the numbers in the database, since people take off and put on attachments all the time. I guess I could use avatar names in the data collection script to eliminate duplicate entries before the data is sent. That might be useful, it might not be. With good numbers I could see a more realistic distribution with regards to what is normal in SL and what is excessive.

Maybe we could use that to come up with a function to give us what kind of script time the average script in SL uses (script count divided by script time). That might be useful information.

Anyway, yeah, I thought Becky's information was old. I hope I can find better information at the office hours today.
bubblesort is offline   Reply With Quote
Old 11-11-2011, 05:49 PM   #19 (permalink)
Imp
 
Gabriell Anatra's Avatar
Who are you?
 
Join Date: Nov 2010
Location: In between.
Posts: 3,394
SL Join Date: Early '06 or late '05, not sure.
Client: Singularity, mostly.
622k is pretty heavy for an AO. 200-300k would be good, that's what the ORACUL ones are and they're quite nice. Mine is ~130-140k, I think. It's the old ZHAO-II from '08 or so though so it's just got the basics and the sit anywhere and the auto sit-detect bit.

The script time is most important in any case. The colors should probably be keyed to that.
Gabriell Anatra is offline   Reply With Quote
1 User Agreed:
Old 11-11-2011, 05:53 PM   #20 (permalink)
Senior Member
Invisible
 
Join Date: Sep 2010
Posts: 2,235
Quote:
Originally Posted by bubblesort View Post
I like Darik's idea of putting a notice in the marketplace listing telling people not to be idiots with this. I really don't have the authority to tell people what to do with it, I can just suggest uses for it. JLU type ass hats are always going to find reasons to mess with people, whether it's with this HUD or whether it's with average rendering cost.
Pretty much, suggestion is all you can do. There will be some who will be idiots with this anyway but that's beyond your control. They'll be idiots without it, regardless.

I wonder whether there is a way to determine what's causing client lag and is there a system of checking that that could be utilized into a HUD, as well.
Darik is offline   Reply With Quote
Old 05-08-2012, 11:53 PM   #21 (permalink)
Beach Girl
 
Miko Masukami's Avatar
Getting a tan on my beach
 
Join Date: Mar 2008
Posts: 86
My Mood:
Business: MIKO'S NUDE BEACH
Client: cup and string
I was just at a popular club and started to get spammed every ten seconds that I had such and such scripts and to take some off to stop the lag...I solved the problem by leaving and never going back...the club is one of the laggiest places anyway even when there are only a few people in it... say good bye to me,I can't be bothered when there are so many clubs that will be happy with my business..
Miko Masukami is offline   Reply With Quote
Old 05-09-2012, 09:19 AM   #22 (permalink)
The Purple
 
Chalice Yao's Avatar
HEYOO!
 
Join Date: Dec 2007
Location: Somewhere purple, Germany
Posts: 8,127
My Mood:
SL Join Date: 20. January 2007
Client: NaCl
Quote:
Originally Posted by bubblesort View Post
@Chalice:

IDK about the 2Mb being too much for an agent to use. My fancy Vista AO puts me 622Kb, which is more than a quarter of the way to the 2Mb point. When I'm wearing xcite genitals, my AO and lightly scripted shoes I'm at 10Mb and 200 microseconds. I personally don't walk around like that but I think it's not an uncommon thing for people to walk around wearing these kinds of things. The script count in these things is high, but the script activity is low, and as you noted there is no way to tell how much memory is actually being used by the scripts. Because of that, I'm thinking that script time is better for measuring resource usage.
Script time isn't better for measuring resource usage. It simply measures a different resource. But I agree that the displayable script memory is kind of misleading unless more people use llsetmemorylimit to properly display how much their gadget uses max.

Still, what 10MB -does- tell me is that way too many scripts are involved in your items. It's the Xcite. They are horrible, sorry to say it. I'm wondering a little about the AO as well. Oracul's, as was said, is more efficient. I guess making an AO will get added on my list of stuff to make
Chalice Yao is offline   Reply With Quote
Old 05-09-2012, 09:53 AM   #23 (permalink)
Senior Member
 
Adeon Writer's Avatar
On vacation! Be back Jan 4
 
Join Date: Apr 2010
Location: Pennsylvania, US
Posts: 8,429
My Mood:
SL Join Date: May 2007
Client: Singularity

Awards: 2
SLU Creepy Avatar Competition 2014 Participant 
Send a message via Skype™ to Adeon Writer
Just name animation files to be exactly the name of their slots, and do llStartAnimation(llGetAnimatiom(llGetOwner()))

Boom, super efficient, no-frills AO.

(I use it for tinies)
Adeon Writer is offline   Reply With Quote
1 User Likes This:
Old 06-05-2012, 04:28 AM   #24 (permalink)
Tea Bitch

*SLU Supporter*
 
Tyche Shepherd's Avatar
Cherry red lips and sick on her boots
 
Join Date: Aug 2007
Location: UK
Posts: 8,261
My Mood:
SL Join Date: 26th April 2007

Awards: 1
Best Anglo-Saxon High Horse Reference 
From this thread now why would someone in a sl region be portscanning my pc?

Quote:
Originally Posted by bubblesort View Post
Thanks for that database! I'm going to use your API in the next version of the Lag Radar HUD.
You are welcome , that's what the API is there for.

Looks like your LoadRegion function would be a good home for any calls to Gridsurvey as the data changes at most once a day so only needs to be called at that frequency or when the local region changes.
__________________

Vanguard of the LolCatz Revolution
This Post was financed by The National LolCatz Archives

Clancy Sullivan :Yeah. YEAH! The sultry seamstress of mirth is definitely in charge now.
Certified 7.8 on the Official Non-Arbitrary Trout Algorithmic Slut scale

A public copy of my Second Life Main Grid Survey Database can be found at http://www.gridsurvey.com - Now with added Second Life Incidents !!


Tyche Shepherd is offline   Reply With Quote
Reply

Tags
hud, lag, opensource, radar

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On