#pathfinding latency

1 messages ยท Page 1 of 1 (latest)

balmy phoenix
#

starting a thread just in case

umbral pumice
#

can you

#

uh

#

send the function Pathfinding.GetLowestFCostPathNode()

#

and FindPath()

balmy phoenix
umbral pumice
#

ok what is openlist

#

also to catch you up to speed

#

in case you dont know how to read the call stack

#

uh getting the length of the list is taking forever

balmy phoenix
#

yeah! im not sure why it takes so long when its a native array

umbral pumice
#

what is the length of the list?

balmy phoenix
#

unity froze for like 1min trying to print

#

44 max length i saw but its an array per path finding request

#

44 * x(number of paths) * y (number of possible move positions)

umbral pumice
#

uh

#

why does it print so many times

#

how many times do you call GetLowestFCostPathNode

#

ill just abbreviate to GLFC

balmy phoenix
#

ok

#

it calls it 1000+ times

#

so im pretty sure becuase..

enemy units have like 8 or more possible move locations right, so for each move location i find a path to each location

#

but i think the numbers are too high for that

umbral pumice
#

weirdly the atomic call isnt a blocking one so it shouldnt take very long

#

its checks the handle

#

im not sure what that consists of tho

umbral pumice
#

dont forget the profile is per frame because that info provides a lot of context

balmy phoenix
#

that seems even more wrong now

#

hmm then again...

umbral pumice
#

well that 3k ms might just be on one specific frame

#

no clue how often you are running this

#

its on button click tho right

balmy phoenix
#

yeah

umbral pumice
#

so it would just be one frame

balmy phoenix
#

i can link a vid?

#

but you can kinda see it when i press end turn or complete a move action with the player unit

umbral pumice
#

interesting

#

what does profiler look like on this one

balmy phoenix
#

very similar to what i linked

#

just reduced

#

at the end of every action and turn all the enemy units revaluate what action they should do and where they should do it

umbral pumice
#

same functions

#

?

balmy phoenix
#

same functions

umbral pumice
#

namely the atomic one is interesting

balmy phoenix
#

just less calls

#

atomic? oh yep

#

i googled that for a bit

umbral pumice
#

did you figure anything out

balmy phoenix
#

not really tbh, i dont understand why it uses that method on the backend when its a native array

umbral pumice
#

the docs say

#

uh

#

hold on

#

this page

balmy phoenix
#

yeah it doesnt use the job system though?

umbral pumice
#

You typically do not need to use this type in your code unless you are implementing your own NativeContainer type.

#

so it is related to Native containers

#

im not actually sure what a native container is

balmy phoenix
#

NativeArray<PathNode> pathNodeArray = new NativeArray<PathNode>(_cells.Count, Allocator.Temp); oh shit...

#

maybe this?

#

NativeArray<int2> neighbourOffsetArray = new NativeArray<int2>(8, Allocator.Temp); other containers are just simple types

umbral pumice
#

does that call getlength tho

balmy phoenix
#

ahh no it doesnt

umbral pumice
#

because it is VERY specifcally

#

this

#

step one

#

it has to be under GLFC

#

step two

#

it has to call getlength

#

thats where you performance is going

balmy phoenix
#
    private int GetLowestFCostPathNode(NativeList<int> openList, NativeArray<PathNode> pathNodeArray)
    {
        PathNode lowestCostPathNode = pathNodeArray[openList[0]];
        for (int i = 1; i < openList.Length; i++) 
        {
            PathNode testPathNode = pathNodeArray[openList[i]];
            if (testPathNode.fCost < lowestCostPathNode.fCost) 
            {
                lowestCostPathNode = testPathNode;
            }
        }
        return lowestCostPathNode.index;
    }

doesnt call it though

umbral pumice
balmy phoenix
#

ya open list is just ints though

#

not pathnodes

umbral pumice
#

literally no clue

#

that is code that is calling get_Length

balmy phoenix
#

haha ๐Ÿ˜ฆ

#

yep

umbral pumice
#

and get_length is taking 83.3% of the frame

balmy phoenix
#

i wonder if i can just get the length once or something.. but that doesnt work cause of the nature of using the open list pattern i think

umbral pumice
#

oh shit you know i just saw this cool tab

#

calls

#

very cool

#

so GLFC gets called 1.3k times

#

and getlength 52.4k

balmy phoenix
#

yeah crazy

#

i dont think calling get length 52k times is right

#

im trying to work out the math

#

bah maybe that is right

umbral pumice
#

actually seems plausible

#

since you start at i=1

balmy phoenix
#

yeah i tink so as well

umbral pumice
#

and it called 52389

#

times

#

so if you start at i=0 it should be 52390

#

well

#

no

#

since you run the loop multiple times

balmy phoenix
#

yeah ^ exactly

umbral pumice
#

1315 calls of GLFC

#

oh the length changes

#

i forgor

#

just coincendence then

balmy phoenix
#

yep

#

๐Ÿ˜”

#

im a bit stuck, thanks for taking the time to understand the issue, no stress if you have no advice for me

umbral pumice
#

btw

#

what are those small spikes in frametime'

#

the ones a few hundred frames before the big spikes

#

like that

balmy phoenix
#

oh

#

i think just creating the unit or instantiating something like the projectile

#

i dont have pooling or anyhting yet

umbral pumice
#

idk that that should take so long

#

is this DOTS

#

ive never used DOTS

balmy phoenix
#

its not dots

umbral pumice
#

oh

#

idk what pooling is then

balmy phoenix
#

like creating a bunch of gameibjects at once

#

and disabling and enabling them as required

#

not important for this pathfinding though

umbral pumice
#

yeah

#

where is a nativecontainer expert

#

smh

balmy phoenix
#

hahah yeah

#

fuck this is annnoying me so much, i need to fix this before moving on, i hate leaving it like this

pearl python
#

is it?

#

it's a 2d movement grid

#

there's a lot going on here

#

and you have written a lot of code

#

and you are using nativearray for some reason

#

your profiler is telling you that you are using the nativearray api wrong

#

but it also looks like you're deep profiling

#

which doesn't mean what you think it means

#

you're at the start of a long journey

#

there are 52k calls, but there are only maybe 400 spots that need to be checked

#

so this is a huge bug

#

what is your goal?

#

to have a working game?

balmy phoenix
#

haha yes the goal is to have a working game

#

yes pathfinding is only in 2d because we don't have cells underneath the cells on a higher level so we can get away wth it

#

are there 400 spots?

#

the profiler is showingl ike 5-8 units all checking for a location to move to

#

not just 1

#

i see what youre saying but i duno how to debug it further

#

@pearl python

pearl python