#regarding the performance of accessing
1 messages · Page 1 of 1 (latest)
Well, managed arrays have their own dedicated IL instructions for reading and writing to them, so JIT can easily optimize it.
But I think if you convert the NativeArray to a Span, you should see major improvements.
This can be done without any additional allocations, since Span can reference native memory.
Unity 2022.2+ have NativeArray.AsSpan, but you can also do it manually using GetUnsafePtr and passing that into the Span constructor. It just requires an unsafe context.
I just tried this and got about a 50% speed improvement. Which is only a little bit faster than ToArray, except no allocation.
and you're not profiling in the editor with safety checks on, right? Because that adds a ton of overhead that won't be present in actual use cases
that thing toggled itself back on, I think they do that on each package update :/ Toggled it off and see no change in speed.
Oh no, 44,5mb of GC
Never done that, that's very cool. I had a out of index thingy because I rely too much on gpt4 😄
It's actually a 15x difference in the editor, 2x improvement in Mono build, and exactly no difference in IL2CPP.
and same perf as ToArray but without the silly allocation
much better
still concerned about the time it takes
i agree it is too slow. testing 5M cells i might have to make a job
Ahhh, I thought this was on jobs already, then yes, it should help, but Im curious, why is this being called everyframe on late update?
It's how I debug stuff. The end goal is to get two disparate systems to talk.
the Draw.WireBox command is like Drawgizmo but 100x faster
Ahhh, alright, I understand
liquid type and density, then map it to voxel. I think it'll be one system once out of proto stage.
Great! since this is the case, then jobs will boost this for sure, but keep in mind in case you are using a 2D array for voxel data, you will need to flatten it, because jobs cant take multi dimentional arrays
and feed the voxel navigation system as well so that flying creatures dodge or dive in the liquid
compute butter.GetData spits out a flat array
Great, much easier then
another note would be to use unity mathematics instead of default unity Mathf functions, mathematics should be faster than Mathf and also are designed to work onto jobs. I am not sure if it would be necessary to convert vector3 to float3, not sure if it actually improves performance, but In my voxel project I did that just in case
in the past mathematics had an overhead so in main thread there was a penalty, but if I jobify this I'll switch over. someone told me that vector3 is already float3 under the hood
I didn't know vector3 was a float3 already, thanks for the info thoug
mmm from 16ms to 7ms, doesn't seem right for a paralell bursted job
deep profile the root of what takes the more ms
your ms should go lower