eronoobos / BABAR-The-Shardifant

Balanced Annihilation & Balanced Annilhation Reloaded configuration for Shard
2 stars 1 forks source link

increase of lag #72

Open pandaro opened 8 years ago

pandaro commented 8 years ago

i noticed a increase of "lag" in advanced state of battle, i think is lasts commits, possible? you notice?

eronoobos commented 8 years ago

Yeah, same.

eronoobos commented 8 years ago

I don't think it's your commits today, I noticed lag yesterday

eronoobos commented 8 years ago

Never mind. What I thought I was noticing was just my antivirus software or something. When did you start noticing more lag in the late game?

eronoobos commented 8 years ago

Ugh, yes, huge spikes in cpu usage in the late game. I think it will be extremely tedious to find the cause, because the symptom doesn't arise until very late in the game.

eronoobos commented 8 years ago

hm i can only seem to reproduce it with more than one AI team

pandaro commented 8 years ago

can you check your commits of 19/7, maybe is here

eronoobos commented 8 years ago

you mean https://github.com/eronoobos/BABAR-The-Shardifant/commit/d35126a6d13d4930701f99f03423c5ed7131f326 ? or the day before?

i've narrowed it down to either defenders or attackers. if i destroy every attacker/defender the lag goes away, and comes back if i give some. possibly my new attack movement algorithm is just that expensive?

eronoobos commented 8 years ago

except that everything is smooth in the early game, even if i give it a bunch of attackers

pandaro commented 8 years ago

you mean d35126a ? or the day before?

yeah i referred to this, but was just an idea. I try to find out where are jump out the dog from the grape.

pandaro commented 8 years ago

so... the lag income when the amount of mobile attackers are high (like 100 or more)

eronoobos commented 8 years ago

hm ok. that should not have changed for the worse recently. if anything, it should have gotten better (the distance calculations no longer involve square root, and are done every 5 seconds instead of every 2), but possibly it's doing something unexpected

pandaro commented 8 years ago

maybe the the problem was already here and i don't noticed before as an aside, there is a way or can be create a way to monitor the computing work file by file, to have an idea on how much power consume for example taskqueuebehaviour? this can be implement only file by file? or we can have an system to do this before? i dont know but, in shardlua, where a "behaviour:update()" is called, can we know for example the time needed for doing all the callin? this can be a system to monitor the resources consumption

eronoobos commented 8 years ago

i got some stats for modules, i need to add behaviours, because it's clear that that's where most of the computing time is going: screen02819

will link to commits when the statistics-gathering stuff is more complete

pandaro commented 8 years ago

wtf but how fast are you in expire my desire i will try it now!

wait, i take a look with your (on my idea) new nice timerRespons add-on resourcesconsumpt

you can see that unit handler is on the top of the hill, but we have a complex conjure of callin that push up lag: turtlehandler:mostturtled targethandler:checkhorizontalline targethandler:checkradious targethandler:isbombardposition targethandler:check4

pandaro commented 8 years ago

and ShardSpringLua.sdd/luarules/gadgets/ai/unithandler.lua contain the Update that are always on top on resources drain this update is the update that call all the update inside all the behaviours?

eronoobos commented 8 years ago

yup, that leads to unit.lua, in which each unit updates its behaviours

https://github.com/eronoobos/ShardSpringLua/commit/ed3a86bde5c7f6964dd84cd86b24fdada3cb48bd

eronoobos commented 8 years ago

Oops, forgot you need to give all the behaviours a :Name() for this to be useful

pandaro commented 8 years ago

ok, the form is this? function DefendBehaviour:Name() return "defendbehaviour" end we need to check all behaviours to see if there are this function?

pandaro commented 8 years ago

and handlers files are checked too?

eronoobos commented 8 years ago

Yes. I already did it in my local repo but I'm not at my computer do can't push

Modules already have name functions

pandaro commented 8 years ago

using debug i see that there are 3 number per function showed, what exactly mean each number? as an aside interesting data can be: total amount of call for each function media of duration of function call just a issues

eronoobos commented 8 years ago

Three numbers are: Sum | min | max Milliseconds per call for all calls from the last 4 seconds

eronoobos commented 8 years ago

https://github.com/eronoobos/ShardSpringLua/commit/2c41882918bac202536611c8366fc240692f63dd

screen02822-crop

eronoobos commented 8 years ago

https://github.com/eronoobos/ShardSpringLua/commit/a3b1eeb2795eb5435e8d398df8b5507875da2021 easier to read, but hope you have enough screen space

eronoobos commented 8 years ago

i'm just going to leave it here collecting info for a while

eronoobos commented 8 years ago

oops, it went off the screen. maybe 10 pixels high per row was better than 15. hm, i should have the widget print all this to the info log at the end of the game. that way i can just leave a game running (even a headless game) and walk away.

eronoobos commented 8 years ago

screenshot before it went off screen screen02826

eronoobos commented 8 years ago

https://github.com/eronoobos/ShardSpringLua/commit/f40799bf007d3ab653cdb758976ed9c8c6a21796 https://github.com/eronoobos/ShardSpringLua/commit/2bb87a0b5c9bdb7dd9095998a2532b7d8eb3c9ef

eronoobos commented 8 years ago

http://pastebin.com/udMVphN2

things i see to optimize, going by their maximum ms: RaiderBehaviour:Update TaskQueueBehaviour:Update (presumably this only because it leads to ProgressQueue) TurtleHandler:MostTurtled AttackHandler:DoMovement

pandaro commented 8 years ago

ideas 1- cut the timer counter at 3rd or 2nd after "," (0.00 or 0.000) 2- delete all the function and refill screen every 4 seconds adding only called function 3- save in a file output list like the one linked

pandaro commented 8 years ago

turtlehandler:mostturtled targethandler:checkhorizontalline targethandler:checkradious targethandler:isbombardposition targethandler:check4

this function for me is a problem when the battle become great, i noticed a particular case of lag, when AI have adv and after, that show this 5 function all "red" at same time. where this 5 function are called each other?

eronoobos commented 8 years ago

https://github.com/eronoobos/BABAR-The-Shardifant/blob/dae418bc6b7b6a608c561cadaf787687ab89c115/taskqueuebehaviour.lua#L393 https://github.com/eronoobos/BABAR-The-Shardifant/blob/dae418bc6b7b6a608c561cadaf787687ab89c115/turtlehandler.lua#L585 https://github.com/eronoobos/BABAR-The-Shardifant/blob/dae418bc6b7b6a608c561cadaf787687ab89c115/targethandler.lua#L1128 (check4 is called many times by checkradius)

so it's looking for positions to build big plasma cannons

pandaro commented 8 years ago

i will rewrite the defense placements because you say that but now is not the time, i will work on fix and fix again

eronoobos commented 8 years ago

these things are not related

pandaro commented 8 years ago

oh sorry, plasma are not defense

pandaro commented 8 years ago

you online? can we talk a bit?

eronoobos commented 8 years ago

i thought my overhaul of attackhandler and attackbehaviour would help, but it did not

the lag makes it basically unplayable in the late game. maybe it's the big plasma cannon placement

pandaro commented 8 years ago

i suspect that there something in the building placement of t2 ground eco that cause the lag, one of this can be the plasma

pandaro commented 8 years ago

now using debugging rising me some doubts: this is the 3rd line [f=0041390] CountBehaviour:Update 0 39.7018089 0.001 0.00000429 9250307 just a question where the f..k is called countbehaviour:update simple there is not in all the shard so why is called? why is called 9250307 times

eronoobos commented 8 years ago

because it's called for every unit every frame. but it has nothing defined, so an empty function is called

pandaro commented 8 years ago

is insignificant ok... another info: i checked the big plasma in taskqueuebehaviour find position system i do not think is a real problem deleting the calls don't get a real benefit for lag but i noticed that in 99% of find location for plasma, no position is find

pandaro commented 8 years ago

is not insignificant maybe, there is not a way to set up custom behaviours with dedicated function? if i need a behaviour without update... or other calls..

eronoobos commented 8 years ago

Behavoiurs that do not define an Update or UnitCreated or whatever just call an empty function when those conditions come up.

pandaro commented 8 years ago

Re editing i rechecked all plasma and nukes i forgot to delete t1 plasma a large problem is here effectively. and starting with most turtled so for normal nuke i can resolve by using nano search or other location system but is not the solution other plasma need a line of sight i think and a bombard position too what you think?

Behavoiurs that do not define an Update or UnitCreated or whatever just call an empty function when those conditions come up.

is an idea or what?

eronoobos commented 8 years ago

is an idea or what?

It's not an idea. It's what already happens. I'm trying to explain why I don't see the purpose of the custom behaviours you describe.