Serious performance bug with Instanced Static Mesh

Please let me start by saying that it is absolutely critical that I resolve this issue. If this issue is not resolved, our entire game design will not be feasible.

Summary of the problem:

Adding instanced static meshes in a random order by location gives 25% of normal frame rate, compared to adding them in order by X,Y,Z location.

It took me days to track down exactly why I was getting 30 fps when spawning 100k blocks using a random location, but when I spawn then in a grid, iterating over x and y, the fps is over 100. Everything else is exactly the same. PLEASE help me fix this problem. I would have to find another engine if this can’t be fixed. I am providing a github link and screenshots.

Steps to reproduce the bug:

1.Load the attached project.

2.Begin Play.

3.Observe fps.

4.End Play.

5.Enable the bool “Use Random Order” in my ism_spawner blueprint.

6.Begin play

7.Observe fps.

I downloaded the project and I have reproduced OP’s result, it appears this is an engine bug.

It’s been over a week since I posted this. Could someone on staff please respond? This is really important to our game.

Have you tried cpu profiling? It might help you point out where all the cpu cost is going.

I have, and I think it has something to do with the way the physics engine handles collision. This project is very bare bones, so there isn’t anything I can change. There needs to be a way to add and remove instances at random locations.

This is critical for cutting down a forest in game and having it grow back, or placing blocks for bases. If you were to say “try using less blocks”, then we are simply ignoring this bug. There is no good reason that we get 4x performance for placing the instances in a specific order.

We have a situation where the number of blocks must be hard capped at a very low number, because the complexity of adding additional blocks becomes greater than O(N). See image below.

Please feel free to download the project using the link posted above, and try it yourself.

Hi mgumley ,

Thank you for submitting a bug report. I have reproduced the issue and logged it as UE-43692 which you can track on the following link: Unreal Engine Issues. Please be aware that since the issue must be reviewed and prioritized by our development staff, it may be a while before it can be addressed.


Thank you so much for looking into this .

There is one small mistake in your bug report. You accidentally reversed the outcomes. The frame rate is worse when using random order, not better.

I have made this correction, thanks for pointing that out.

Workaround: link text
This is a single blueprint (Yours but modified by me :smiley: )
Hope it will help

Thank you for this attempt. Would it be possible to post a screenshot of the blueprint? I don’t know enough about scanning files like this for malware.

lolmedve, I loaded your workaround and I was not able to reproduce any performance gains that address the subject of this post.

In the bug report UE-43692, step #1 says “linked removed”, is this normal for non-staff? I’m not sure if they will be able to understand the bug without the content of this post.

The link is still there for staff, we just remove links when making the ticket publicly visible.

Sorry for late reply. This attempt gave me different results because I’ve used high poly meshes with LOD enabled (I don’t really know why the hell) Since then I’ve tried nearly every possible way to get it working, generated fully new array from the provided data (without any loss of the original array not like before) but it gave me the same result. Your problem will be with the engine itself if we can call this a problem. The engine is simply reading ordered data faster(only in case of having the same numbers through several datablocks) Sorry for the inconvinience that I’ve made. Have a nice day :slight_smile:

Want to add a bit of more info I could dig down to:

Can confirm it is related to the Order they Spawn in (still slow):

Digged a bit deeper with the Profiler an noticed PhysXTask is going Mad with the Random Order (Console command “stat Physics”)

And indeed the Performance is the same as in Order if you Turn off Collision in the Instanced Static Mesh Component.

Thats how far I willing to go but should give the Staff a Hint in the right Direction. (Sry not in Sourcecode mood today ^^)

Thank you for this additional information. I have added it to the bug report.

The bug report (UE-43692) is marked as “cannot reproduce”?! My project on Github demonstrates the issue very clearly. Could you please look into this?

So it’s been nearly a week with no answers. This post have over a hundred views. It was acknowledged by and many other people that were able to reproduce the problem. My team literally cannot continue making our game until this problem is fixed. The fps is unplayable. What is it going to take to get this resolved?

It appears they have done something in 4.16.1, but the problem is still not fixed. If you look at these two screenshots, you’ll see that there is an intolerable amount of frame rate jitter when using the random order mode.

Please note that the problem does not occur if the camera is not translating it’s location. You must be moving to notice the effect.

If the rendering is the problem, then there’s functionally no difference between spawn type one and spawn type two except that when spawning in an orderly way, the instanced meshes are probably batched together more intelligently.

Wouldn’t it be reasonable to assume that totally random spawning at runtime will cause the batching of meshes (and therefore your culling, occlusion, LOD’s) to become intertwined in undesirable ways?