Copying group of actors may be very slooooow

Hi,

I have a map with 20k+ actors and when I’m trying to copy a group of actors 200+ the editor can freeze even for +20 minutes. My current engine version is 4.4.

I can easily reproduce this behavior on 4.3 shoter game HighRise map, I copied actors that whole level contains ~3300 actors and grouped 315 actors, then copy, editor freezed for ~30 seconds.

Bigger map, more actors, bigger groups = more pain and I believe the main bottlenect is within:

void UEditorEngine::SetActorLabelUnique( AActor* Actor, const FString& NewActorLabel ) const

Best regards

Pierdek

bump bump

Hi Pierdek,

How long it takes to copy a large amount of actors depends on the complexity of the actors themselves and your hardware setup. The scenario you described in Shooter Game is standard behavior when copying that many actors.

As for what you are seeing in your project, 20k actors in one scene is quite a lot. You may want to consider Level Streaming, hiding groups of assets that you aren’t working on, using Unlit Mode, or turning off certain process heavy features in the Perspective Viewport (Anti-aliasing, Particle Sprites, etc.).

TJ

HI TJ

I do not agree with you, my rig(I7,32 GB RAM, GeForce GTX 770), isn’t bad for UE4. Our level is divided on smaller subleveles, yes we were preparing streaming.

using Unlit Mode, or turning off certain process heavy features in the Perspective Viewport (Anti-aliasing, Particle Sprites, etc.).

These setting doesn’t affect copying actors!

But take a look on function UEditorEngine::SetActorLabelUnique

void UEditorEngine::SetActorLabelUnique( AActor* Actor, const FString& NewActorLabel ) const
{
	check( Actor );

	FString Prefix             = NewActorLabel;
	FString ModifiedActorLabel = NewActorLabel;
	int32   LabelIdx           = 0;
        
        //Pierdek: first loop
	for (;;)
	{
		// Check for a duplicate actor name
		bool Duplicate = false;
                //Pierdek: second loop this creates iterator from level _P which iterating over all actors, not only on level where actor is placed, so streaming doesn't gives any advantages
		for (FActorIterator It(Actor->GetWorld()); It; ++It)
		{
			if (Actor != *It && It->GetActorLabel() == ModifiedActorLabel)
			{
				Duplicate = true;
				break;
			}
		}

		
	}

	Actor->SetActorLabel( ModifiedActorLabel );
}

Check my comments in code and as you see there is O(n^2) - 2 loops in this function with simple hashmap you can get O(1) which is much faster.

I got with our devs on this and it seems a optimization fix was just submitted for this bit of code. Copying large amounts of actors will still be an expensive operation, but this fix helps streamline the process.

Look for the adjustment to be included of a future editor update.

TJ

Sure, thanks :wink: