BehaviorTree causing performance drop on actor spawn during RunBehaviorTree in the AIController

I’m not sure what’s causing it, but BehaviorTree when initialized is causing a massive performance drop when RunBehaviorTree is finally called in the AIController when spawning in new AI. The AIs constructor is insanely fast, but the BT is taking 0.4ms per AI and when you multiply that by say 50 it’s a bit of a problem.

Below is my BT.

I don’t feel like I’m doing anything crazy complex here. Any idea why it’s taking so long to initialize? Maybe the initial call to the service is doing it?

Below is my service.

I think the StaticDuplicateObject is the part that is more responsible for the slowdown. If you are spawning 50 characters then maybe stagger the spawn process over time?

They’ll be staggered in live gameplay, but just curious if this can be sped up in general. Seamed strange the longest running process for spawning in my AI was just the BT initializing. So seamed like maybe a bug or I’m doing something wrong.

Is this on an older version of the engine? StaticDuplicateObject has been deprecated in favor of StaticDuplicateObjectEx in newer versions.

Nope, I’m on UE 5.1.

Do you have a heavy construct & begin play for the ai characters?
Maybe many calls of get all actors of class per ai character?

Nope, there is no constructor behavior for the AI and the below is their BeginPlay.

Need to figure out these Insights tools and see if I can dig a bit deeper and see what’s going on.

Just a guess, but maybe you have some hard references inside your BT? You can check references of the BT and see how deep it goes.
If you reference something in BT that references other things (and so on) all of it will be loaded with this BT which may cause some spikes.

There’s no hard references. I’m working with generic actor objects and interface functions pretty exclusively throughout the entire game. I don’t think I’ve a single cast anywhere. Even communicating to widgets I’m doing so through interfaces.

Having a hard time reading the overload of information in Unreal Insights. Trying to get a better picture of what’s going on to track down exactly what call is causing this and where. Hopefully that’ll give me more info, but good lord this tool is just too hard to read.