Volt-Host CPU usage over 100%
#1

Well, basically I believe that my script is eating CPU. Sometimes (not all the time) the CPU usage gets up to 120%, reported by the Volt-Host server information page else it only uses around 15%.

Fuel system (I do not think that this is the problem):

pawn Код:
//OnGameModeInit:
SetTimer("VehFuelTimer", 40000, true);


//---



public VehFuelTimer()
{
    new iEngine, iLights, iAlarm, iDoors, iBonnet, iBoot, iObjective;
    for(new i; i < MAX_PLAYERS; i++)
    {
        if(GetPlayerVehicleSeat(i) == 0)
        {
            new veh = GetVehicleModel(GetPlayerVehicleID(i));
            if(veh == 481 || veh == 509 || veh == 510)
            {
            }
            else
            {
                if(!VehAdmin[GetPlayerVehicleID(i)])
                {
                    GetVehicleParamsEx(GetPlayerVehicleID(i), iEngine, iLights, iAlarm, iDoors, iBonnet, iBoot, iObjective);
                    if(VehFuel[GetPlayerVehicleID(i)] < 1) SetVehicleParamsEx(GetPlayerVehicleID(i), 0, iLights, iAlarm, iDoors, iBonnet, iBoot, 0);
                    else
                    {
                        if(iEngine == 1)
                        {
                            if(VehFuel[GetPlayerVehicleID(i)] > 0)
                            {
                                VehFuel[GetPlayerVehicleID(i)]--;
                            }
                        }
                    }
                }
            }
        }
    }
    return 1;
}
I also checked that MySQL would free data after every select..
Reply
#2

Anyone?
Reply
#3

Profiler Plugin.
Reply
#4

Use the Profiler plugin, read more about it HERE.
Reply
#5

Код:
Failed (/usr/lib/libstdc++.so.6: version `CXXABI_1.3.5' not found (required by plugins/profiler.so))
Server is on Volt-Host which uses Linux.
Mysql, sscanf, fixes2 and incognito's streamer are the loaded plugins.
Reply
#6

Bump
Reply
#7

CPU usage graph:

http://volt-host.com/graph/gs/proc/9418/1.00/24/

It goes up really high at some times and becomes unresponsive.. Da heck?
Reply
#8

try adding IsValidVehicle check in your loop
Reply
#9

I forgot to say that I remade the fuel system to check per player with the negative thing being that it doesn't use any fuel when the vehicle stands still, but that's something I can oversee for performance.. BUT, I still get peak CPU usage for some reason..

pawn Код:
public VehFuelTimer()
{
    new iEngine, iLights, iAlarm, iDoors, iBonnet, iBoot, iObjective;
    for(new i; i < MAX_PLAYERS; i++)
    {
        if(GetPlayerVehicleSeat(i) == 0)
        {
            new veh = GetVehicleModel(GetPlayerVehicleID(i));
            if(veh == 481 || veh == 509 || veh == 510)
            {
            }
            else
            {
                if(!VehAdmin[GetPlayerVehicleID(i)])
                {
                    GetVehicleParamsEx(GetPlayerVehicleID(i), iEngine, iLights, iAlarm, iDoors, iBonnet, iBoot, iObjective);
                    if(VehFuel[GetPlayerVehicleID(i)] < 1) SetVehicleParamsEx(GetPlayerVehicleID(i), 0, iLights, iAlarm, iDoors, iBonnet, iBoot, 0);
                    else
                    {
                        if(iEngine == 1)
                        {
                            if(VehFuel[GetPlayerVehicleID(i)] > 0)
                            {
                                VehFuel[GetPlayerVehicleID(i)]--;
                            }
                        }
                    }
                }
            }
        }
    }
    return 1;
}
Reply
#10

Profiler result on Windows server (real server on Linux): http://pastebin.com/UX35XuKt

Logging in, spawning a car with unlimited fuel (VehAdmin), driving to a non-admin car which has limited fuel, watching the fuel going down a bit, driving to a refuelling station, driving to a dynamic door, use it in and out, go to the police locker and take out some things, quitting which saves the player to the database.

What is weird is that these peaks comes at random times when no-one is online. Perhaps it's because the server is being hosted on Volt-Host which has more than 1 SA-MP server on each dedicated server?

One and a half hour of CPU being around 20% without peaks so far, let's see how it goes.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)