Raised This Month: $32 Target: $400
 8% 

linux entity issues insane cpu load


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
h010c
Member
Join Date: Aug 2009
Location: Mother Russia, Moscow
Old 05-28-2015 , 12:44   linux entity issues insane cpu load
Reply With Quote #1

Tested latest linux HLDS build
Code:
Protocol version 48
Exe version 1.1.2.7/Stdio (cstrike)
Exe build: 13:12:29 Aug 29 2013 (6153)
and found a weird issue.
OS:
Code:
Distributor ID: Ubuntu
Description:    Ubuntu 14.04.2 LTS
Release:        14.04
Codename:       trusty
When creating multiple entities and assigning different attributes to them - server shows some serious CPU load, even on empty server with no plugins(except this one). Tested both fakemeta and engine versions, tested both metamod and metamod-p versions. Testes stable amxmodx 1.8.2, beta amxmodx 1.8.3-d4537, latest beta amxmodx 1.8.3-d4748. All show serious CPU load on an empty server. Linux version only, windows version doesn't have such issues.


These lines are the reason for strange CPU behaviour(any of them or both)
Code:
set_pev(entid,pev_solid,SOLID_NOT)
set_pev(entid,pev_movetype,MOVETYPE_FLY)
Code examples:
Code:
#include <amxmodx>
#include <engine>
#include <fakemeta>

public plugin_init() {
    register_plugin("TEST","engine","h010c")
    MakeEnts()
}

MakeEnts() {
    for(new i=0;i<200;i++) {
        new entid=engfunc(EngFunc_CreateNamedEntity,engfunc(EngFunc_AllocString,"info_target"))
        set_pev(entid,pev_classname,"csdmitem")
        engfunc(EngFunc_SetModel,entid,"models/w_elite.mdl")
        entity_set_int(entid,EV_INT_solid,SOLID_NOT)
        entity_set_int(entid,EV_INT_movetype,MOVETYPE_FLY)
        new Float:fVec[3]
        fVec[0]=random_float(-500.0,500.0)
        fVec[1]=random_float(-500.0,500.0)
        fVec[2]=random_float(-500.0,500.0)
        entity_set_origin(entid,fVec)
    }
}
Code:
#include <amxmodx>
#include <engine>
#include <fakemeta>

public plugin_init() {
    register_plugin("TEST","fakemeta","h010c")
    MakeEnts()
}

MakeEnts() {
    for(new i=0;i<200;i++) {
        new entid=engfunc(EngFunc_CreateNamedEntity,engfunc(EngFunc_AllocString,"info_target"))
        set_pev(entid,pev_classname,"csdmitem")
        engfunc(EngFunc_SetModel,entid,"models/w_elite.mdl")
        set_pev(entid,pev_solid,SOLID_NOT)
        set_pev(entid,pev_movetype,MOVETYPE_FLY)
        new Float:fVec[3]
        fVec[0]=random_float(-500.0,500.0)
        fVec[1]=random_float(-500.0,500.0)
        fVec[2]=random_float(-500.0,500.0)
        set_pev(entid,pev_origin,fVec)
    }
}
Can anyone confim this and submit it to bugtracker if its confirmed?

Last edited by h010c; 05-28-2015 at 22:33.
h010c is offline
GuskiS
Veteran Member
Join Date: Aug 2007
Location: Latvia
Old 05-28-2015 , 13:29   Re: linux entity issues insane cpu load
Reply With Quote #2

And what do you expect in creating that much entities in few seconds?
__________________
Finished mods:
Trouble in Terrorist Town
MurderMod
The Hidden
Cowboys vs Indians
JailBreak Supreme
Survival Madness
GuskiS is offline
JusTGo
Veteran Member
Join Date: Mar 2013
Old 05-28-2015 , 14:19   Re: linux entity issues insane cpu load
Reply With Quote #3

Quote:
Originally Posted by GuskiS View Post
And what do you expect in creating that much entities in few seconds?
still doesn't explain why windows don't have this problem if he is testing on same specs for windows & linux.
JusTGo is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 05-28-2015 , 15:39   Re: linux entity issues insane cpu load
Reply With Quote #4

And how it's amxmodx fault if it happens on latest hlds(so it's a hlds update fault) ?

Quote:
Tested latest linux HLDS build
.

At least, this is what I understood.
__________________
HamletEagle is offline
claudiuhks
Yam Inside®™℠
Join Date: Jan 2010
Location: Living Randomly
Old 05-28-2015 , 21:40   Re: linux entity issues insane cpu load
Reply With Quote #5

Try this?

PHP Code:
#include <amxmodx>
#include <fakemeta>

static g_nInfoTarget 0;
static 
g_uEntities 0;
static 
Float:g_fTimeStamp 0.0;
static 
g_nFwd 0;

public 
plugin_init()
{
    
register_plugin("Name""Version""Author");
    
g_nFwd register_forward(FM_StartFrame"OnServerFrame");
}

public 
plugin_precache()
{
    
g_nInfoTarget engfunc(EngFunc_AllocString"info_target");
}

public 
OnServerFrame()
{
    static 
uEntityFloat:fOrigin[3];

    if (
g_fTimeStamp get_gametime())
    {
        
g_fTimeStamp get_gametime() + 0.125;

        
uEntity engfunc(EngFunc_CreateNamedEntityg_nInfoTarget);
        if (
pev_valid(uEntity))
        {
            
set_pev(uEntitypev_classname"CSDMItem");
            
engfunc(EngFunc_SetModeluEntity"models/w_elite.mdl");
            
set_pev(uEntitypev_solidSOLID_NOT);
            
set_pev(uEntitypev_movetypeMOVETYPE_FLY);

            
fOrigin[0] = random_float(-500.0500.0);
            
fOrigin[1] = random_float(-500.0500.0);
            
fOrigin[2] = random_float(-500.0500.0);

            
set_pev(uEntitypev_originfOrigin);

            if (++
g_uEntities == 200)
                
unregister_forward(FM_StartFrameg_nFwd);
        }
    }

__________________
claudiuhks is offline
Send a message via MSN to claudiuhks Send a message via Yahoo to claudiuhks Send a message via Skype™ to claudiuhks
h010c
Member
Join Date: Aug 2009
Location: Mother Russia, Moscow
Old 05-28-2015 , 22:30   Re: linux entity issues insane cpu load
Reply With Quote #6

Quote:
Originally Posted by GuskiS View Post
And what do you expect in creating that much entities in few seconds?
It doesn't lag at creation time, but AFTER entities have been created an empty server doing NOTHING, being idle, keeps eating CPU badly for the rest of its uptime. And windows build keeps CPU load at 0%.
Quote:
Originally Posted by HamletEagle View Post
And how it's amxmodx fault if it happens on latest hlds(so it's a hlds update fault) ?
I don't know wheter it is an amxmodx fault or this linux HLDS build fault, I am looking if someone can confirm that this problem exists at all or it is just me.

claudiuhks, I can't test it right now, but I'll do it as soon as I have some spare time and post results, thank you for your suggestion. At first I was kinda going to try to create entities with a delay myself, but then on a second thought I didn't see how this could help. But I'll try it.

Last edited by h010c; 05-28-2015 at 22:39.
h010c is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 05-29-2015 , 04:49   Re: linux entity issues insane cpu load
Reply With Quote #7

It's unlikely AMXX fault since it just executes/sets directly game/engine functions.
But it's really not that surprising, engine does a lot of things when creating and setting things around an entity, if you force it to do it 200 times in one frame, for sure it's going to be noticeable. This is bad example which doesn't reflect a server usage.
__________________
Arkshine is offline
h010c
Member
Join Date: Aug 2009
Location: Mother Russia, Moscow
Old 05-30-2015 , 03:41   Re: linux entity issues insane cpu load
Reply With Quote #8

I don't think that I was clear enough with my explanations. Here is what happens:



h010c is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 05-30-2015 , 04:11   Re: linux entity issues insane cpu load
Reply With Quote #9

I don't think I was clear enough with my explanations, this is unrelated with AMXX itself. Feel free to complain to valve that their 17+ years old engine sucks.

You don't seem to understand that your example is invalid and silly. Game will never do that, nor a plugin. You can easily eat CPU by looping thing. Creating and dealing with an entity is expensive, it's obvious if you create/deal 200 in a row, in one frame, it will eat briefly more CPU since you're asking the engine to run a lot of code at once in a very short of time. I'm not sure to get what are you trying to prove.

If you're saying that your CPU is keeping to 30/40%+ after creating the entities, it's expected that it would eat CPU, after all engine has to check many things (entity properties, collisions, etc), it's likely more stressed especially when you create a bunch at the same place. The more it interacts, the more it will cost CPU. That's why you example is quite a bad one.

Note: Please don't PM people, I can see myself there are answers. It's annoying. Don't do it again.
__________________

Last edited by Arkshine; 05-30-2015 at 04:31.
Arkshine is offline
Old 05-30-2015, 04:28
Arkshine
This message has been deleted by Arkshine.
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 05-30-2015 , 05:43   Re: linux entity issues insane cpu load
Reply With Quote #10

Quote:
Originally Posted by Arkshine View Post
I don't think I was clear enough with my explanations, this is unrelated with AMXX itself. Feel free to complain to valve that their 17+ years old engine sucks.

You don't seem to understand that your example is invalid and silly. Game will never do that, nor a plugin. You can easily eat CPU by looping thing. Creating and dealing with an entity is expensive, it's obvious if you create/deal 200 in a row, in one frame, it will eat briefly more CPU since you're asking the engine to run a lot of code at once in a very short of time. I'm not sure to get what are you trying to prove.

If you're saying that your CPU is keeping to 30/40%+ after creating the entities, it's expected that it would eat CPU, after all engine has to check many things (entity properties, collisions, etc), it's likely more stressed especially when you create a bunch at the same place. The more it interacts, the more it will cost CPU. That's why you example is quite a bad one.

Note: Please don't PM people, I can see myself there are answers. It's annoying. Don't do it again.
Arkshine, I think that his point is that this only happen on linux, and not in windows. As I said before, this doesn't seem to be amxx fault. Go and ask Valve.
__________________
HamletEagle is offline
Reply


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

Forum Jump


All times are GMT -4. The time now is 08:55.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode