#SetTiles() slow? 1.5 million tiles, takes over 10 seconds.

1 messages · Page 1 of 1 (latest)

tired mist
#

Im creating a game with multiple tilemaps acting as chunks, however, I am getting huge lag spikes with SetTiles(), if a game like Terraria can handle over 5 milliontiles, then why am I lagging creating and loading basic tiles onto multiple tilemaps with 1.5 million tiles without any complicated algorithims? Just loading into tilemaps.

Am I doing something wrong? Its taking over 10 seconds.

I know I could do it asynchronously, but that would mean I need to store the tile data twice, one on the tilemap itself, and then one in some sort of data structure.

#

To give perspective, I am using burst, so creating the basic structure, setting the tile types, adding caves and other algorithms all take less time than just setting the tiles. Just setting the tiles takes 10 seconds, compared to 2 seconds with the processes.

This is incredibly slow. I understand its to do with the GPU, however, isn't there a way to speed this up ?

ebon scaffold
#

For every optimization/performance question/issue you should always start with looking at the profiler.

tired mist
#

hm, what should I look for in this instance, I usually do, but Im not too sure how to go about it

ebon scaffold
#

For starters get the frame where the spike happens. Then look at the profiler hierarchy. Sort it by time and start expanding the topmost branch.

#

There's nothing complicated about it. It just tells you how much time each function call took to execute.

#

Additional metric thta you should look at is GC alloc - memory allocation and release. It can add to the function time.

tired mist
#

hm okay, I timed it with stopwatch from system.diagostics

#

There technically should only be like 4 allocations, and I already timed that and it was barely anything vs the one function, SetTiles()

#

Im not too sure what to do with this info, since its not really up to me to control

ebon scaffold
#

This is not normal.

#

I'd start with profiling a build.

#

If you look at the last screenshot, it's editor side render loop. Not the player.

#

If you want to look into editor performance, switch player -> editor and capture a frame again.

tired mist
#

Thanks ill look into that tomorrow