#Evaluating Animation Curve Performance

1 messages · Page 1 of 1 (latest)

split comet
#

Hi,

I have an animation curve that is being evaluated inside of a parallel job call. I expect to have ~1million of these calls. Right now evaluating the curve even with only 20k calls is killing my performance. I believe this call is burstable

#

@hybrid rapids

hybrid rapids
#

aha

#

yes that is expensive

split comet
#

the math?

#

even with burst + parallel jobs

hybrid rapids
#

no, the memory access, i would think

#

how large is the array of KeyFrame's

split comet
#

only 2 lol

#

its inside of a blob array, i would expect the memory access to be super fast?

hybrid rapids
#

eh? then how could index < length - 2

split comet
#

do i have the wrong understanding

hybrid rapids
#

i don't understand while (index < (length - 2) && time > keys[index + 1].time) { ++index; } if keys has length 2

split comet
#

one sec

tiny heath
#

that's quite a lot of non-vectorizable math here

hybrid rapids
#

true

tiny heath
#

and rather complex

split comet
#

are there any out of the box ones available? for animation curves, that i can author directly

tiny heath
#

doubt

hybrid rapids
#

i mean 20k of that is just a lot; you could probably get a speedup if you soa'd it and then maybe llvm would vectorize it, or maybe you'd have to use burst intrinsics

split comet
tiny heath
#

but what I personally would try: make an array of 10/20/whatever number of keys from curve. And just use simple lerp inbetween

split comet
tiny heath
#

allthough not sure it'll be much better

split comet
#

i might just use simple functions

#

i don't really need curves to be honest to calculate utility values

#

it's just much nicer to work with

tiny heath
#

my approach does not limit you from using curves though, it just makes it less precise

split comet
#

yeah, i will try that

hybrid rapids
#

just as a sanity check you should also use the burstdiscard trick to make 100% sure you're bursted

#

but i bet it would still be too slow even bursted

hybrid rapids
split comet
#

mystery solved, the animation curve is super performant, its actually the debug logs

#

lol

hybrid rapids
#

damn, i assumed you had deleted that when measuring

split comet
#

nope, i stubbornly thought there was no way some debug logs can be that heavy

#

my mobs are pretty happy now

stuck current
#

@hybrid rapids memory access should not be the problem because he is caching the array index: using the ref int index parameter and it nearly always starts at 0 then binary search is not worth it

hybrid rapids
#

As it turned out all theories for why it was slow were wrong, because it was fast 🙂