Editor perfomance issue

Hi Epic,

I’m working on a plugin which creates one actor with instanced static mesh components for a grid-based game in UE4.10.1.
Since i want good in-game perfomance, i divide the grid into blocks (8x8) and display them on demand only. This works very well, ingame fps is like 70-100 fps, really appreciate that.

But the editor…
Adding many ISMC’s to an actor makes the editor grind to a screeching halt when it has to redo the tree nodes of the actor.
And with screeching halt i mean like 5 minutes total lockout!

The cause for this is easily found:

SSCSEditor::UpdateTree(bool bRegenerateTreeNodes)

Multiple Iterations over all of the components (and the existing treenodes) + double checks for uniqueness (again double iterations).

SSCSEditor::UpdateTree(bool bRegenerateTreeNodes) Line 4357, SSCSEditor.cpp
(Full iteration over all components)

calling (over another function)
FSCSEditorTreeNode::AddChildFromComponent(UActorComponent* InComponentTemplate) Line 564-578 SSCSEditor.cpp
Double check for uniqueness in tree (FindChild + check IsValid() and AddChild (which does again check for uniqueness))

This may work well for few components, but its a really slows the editor down if you get to 1000 or more procedurally created components. For 1000 components it takes the editor 6 seconds to rebuild the treenodes (with the change below just 0.1-0.2 secs).
And it happens everytime you click the actor (selection change in the scene component list).

Loading a map with the saved grid takes only .596s, so the number of components are not the issue here.
It’s the creation of the detail view tree of the components.
Since the editor builds the tree every time from scratch (as i see it from the code), it makes no sense to check twice for uniqueness.

Changing the pattern to just letting AddChild do the check, improves the performance significantly.

I did not find any other relevant places where AddChildFromComponent was called (only one other function, where it returns a new root node, which means, the tree is empty anyway)

So Epic, please can you review this?


FSCSEditorTreeNodePtrType FSCSEditorTreeNode::AddChildFromComponent(UActorComponent* InComponentTemplate)
{
	// Ensure that the given component template is valid
	check(InComponentTemplate != NULL);
	FSCSEditorTreeNodePtrType ChildNodePtr = FactoryNodeFromComponent(InComponentTemplate);
	AddChild(ChildNodePtr);
	return ChildNodePtr;
	/* Old Code
	// If it doesn't already exist in the SCS editor tree
        FSCSEditorTreeNodePtrType ChildNodePtr = FindChild(InComponentTemplate); // Check #1
	if(!ChildNodePtr.IsValid())
	{
		// Add a child node to the SCS editor tree
		ChildNodePtr = FactoryNodeFromComponent(InComponentTemplate);
		AddChild(ChildNodePtr); // Check #2
	}

	return ChildNodePtr;
        */
}

See you after your well deserved vacations :slight_smile:

  • Algorithman