ID:273135
 
You will first have to look at this image to see the problem.

http://www.byond.com/members/TheMagicMan/files/opti.png

An initial look will show you one proc is fairly inefficient, but a closer look will actually show you 3 procs are.

UpdateInterface
UpdateShop
and UpdateTeams

All of these procs are fairly inefficient, and using a lot of CPU for the number of times they are called.
A lot more than any other procs in the game.

Here are those free procs...

UpdateInterface(mob/M)
if(!M.client) return 0
M << output("<B>[M]","default.info:1,1")
M << output("","default.info:2,1")

M << output("<B>Level","default.info:3,1")
M << output("[M.Level] ([M.Exp]/[M.ExpNeeded])","default.info:4,1")

M << output("","default.info:1,2")
M << output("","default.info:2,2")


M << output("","default.info:3,2")
M << output("","default.info:4,2")

M << output("<B>Hp","default.info:1,3")
M << output("[M.Hp]/[M.MaxHp]","default.info:2,3")

M << output("<B>Mp","default.info:3,3")
M << output("[max(M.Mp,0)]/[M.MaxMp]","default.info:4,3")

M << output("","default.info:1,4")
M << output("","default.info:2,4")


M << output("","default.info:3,4")
M << output("","default.info:4,4")

M << output("<B>Str","default.info:1,5")
M << output("[M.Str] ([M.StrGrowth])","default.info:2,5")


M << output("<B>Damage","default.info:3,5")
M << output("[M.DamMin]-[M.DamMax]/[round(M.AtkSpeed/10,0.1)]s ([M.dtype])","default.info:4,5")

M << output("<B>Agi","default.info:1,6")
M << output("[M.Agi] ([M.AgiGrowth])","default.info:2,6")


M << output("<B>Defence","default.info:3,6")
M << output("[round(M.Def,0.1)] ([round(-8+(M.Def*5.2)-(M.Def**1.34),1)]% Reduction)","default.info:4,6")

M << output("<B>Int","default.info:1,7")
M << output("[M.Int] ([M.IntGrowth])","default.info:2,7")

M << output("<B>Mag Def","default.info:3,7")
M << output("[round(M.MagDef,0.1)] ([round(-8+(M.MagDef*5.2)-(M.MagDef**1.34),1)]% Reduction)","default.info:4,7")

M << output("<B>Skill Points","default.info:1,8")
M << output("[M.SkillPoints]","default.info:2,8")

M << output("<B>Gold","default.info:3,8")
M << output("[M.Gold]","default.info:4,8")
if(!M.StatusEffects)
winset(M,"default.status","cells=0")


UpdateTeams(mob/M)

var/v=3
if(Game.Match==1)
M << output("<B>Humanity</b>","default.myteam:1,1")
M << output("Kills: [Game.HumanKills]","default.myteam:1,2")
M << output("<B>Legion</b>","default.eneteam:1,1")
M << output("Kills: [Game.LegionKills]","default.eneteam:1,2")

else
M << output("<B>Humanity</b>","default.myteam:1,1")
M << output("","default.myteam:1,2")
M << output("<B>Legion</b>","default.eneteam:1,1")
M << output("","default.eneteam:1,2")


for(var/mob/E in Game.HumanTeam)
M << output("<B>[E]","default.myteam:1,[v]")
M << output("Class: [E.icon_state]","default.myteam:1,[v+1]")
v+=2
winset(M,"default.myteam","cells=1x[v-1]")
v=3

for(var/mob/E in Game.LegionTeam)
M << output("<B>[E]","default.eneteam:1,[v]")
M << output("Class: [E.icon_state]","default.eneteam:1,[v+1]")
v+=2

winset(M,"default.eneteam","cells=1x[v-1]")


proc/UpdateShop(mob/M,mob/E)
var/v=2

M << output("<B>Item","shop.buy:1,1")
M << output("<B>Price","shop.buy:2,1")
M << output("<B>Item","shop.sell:1,1")
M << output("<B>Price","shop.sell:2,1")
for(var/obj/Items/O in E)
M << output(O,"shop.buy:1,[v]")
M << output("[O.Gold]","shop.buy:2,[v]")
v++
winset(M,"shop.buy","cells=2x[v-1]")
v=2
for(var/obj/Items/O in M)
M << output(O,"shop.sell:1,[v]")
M << output("[round(O.Gold/2)]","shop.sell:2,[v]")
v++

winset(M,"shop.sell","cells=2x[v-1]")



If you have not noticed something strange by now you may as well stop reading here.

All of those procs are literally nothing but a series of outputs.
One of them has some minor math involved in it, but they are nothing more than a list of "M << output()".

Does anyone have any idea at all what is making all of these procs horribly inefficient, and how I could fix it?

At the moment I have done everything I can to reduce how often those procs are called.
Other than not use interfaces, there literally does not seem to be a lot I can do. So any suggestions?
You'll have to be more specific with how these procs are and how often they are being called. From your opti.png image, what were the conditions? IE, how long was the server up, how many players were there, etc.
I think you should look at the average of those numbers.
In response to Kaiochao
The point is, the averages are pretty easy to figure out from that image.
And the average of all those procs is very high for how often they are called.

The average of UpdateInterface in that screenshot is 0.007
The average of UpdateShop is 0.050 (this is the highest CPU usage for a single call of any procs in the game, luckily it is not called very often)
The average of UpdateTeams is 0.009.

In comparison, the average of Attack is 0.001.
The average of AI_WalkPath is something like 0.00006.

The point is, these procs are using abnormally high amounts of CPU for what they are doing.


The same applies to what Devourer of Souls said.
The amount of times a proc is called, how many players are online or how long the server was up are all irrelevant.
The fact is those procs are way more intensive on the CPU than literally anything else in the game.

What I am trying to find out is why.
These procs do nothing but output a bunch of words and/or icons to a grind that is part of the interface.
In response to The Magic Man
No, I'm pretty sure it's entirely relevant if you want help. Of course, if you want to act like a know-it-all despite asking for help on the forums, then you can figure it out on your own.
In response to Devourer Of Souls
No, it is entirely irrelevant.

I am saying, those procs I listed use way to much CPU each time they are called.

This is not an issue with how many times they are called, or how often they are called.
With the exception of UpdateTeams, they should not be effected by the number of players online.
Nor should how long the server has running effect anything (and indeed it does not, the average CPU usage per call from these procs is similar, whether the server has been running for 1 minute, or 1 day).


What I am saying is, the average CPU usage of these procs is abnormally high, for how simple they are.
UpdateShop is by far the most inefficient proc in the entire game, with an average CPU usage of 0.050 per call (the next highest CPU usage is an inbuilt RscFile proc, and that uses 0.022/23 CPU per call). And all it is doing is looping through a list of about 50 objects, and outputting them to a grid.
Try checking the average checkbox, you'll actually see that they don't use much CPU usage at all per call.

You also need to consider the processor, number of players, and the length of time the game has been up.
In response to Axerob
Nice job not reading any of the other posts ;p

Now Magic Man's going to be angry at you :o
In response to Spunky_Girl
Spunky_Girl wrote:
Nice job not reading any of the other posts ;p

Now Magic Man's going to be angry at you :o

Oh I read the posts ;) and he's always angry...!