Mutable Perf When Copying DNA Object

Hello!

We are investigating performance issues with Mutable, and one that has come up is when copying the DNA object inside URigLogicMutableExtension::OnSkeletalMeshCreated. For skeletal meshes that are created for runtime-only scenarios, this copy is resource-intensive. Is there a good way to avoid this or are there any dangers to trying to avoid it? Locally, we’re trying the below, and that seems to work in a pinch, but we’d like to know if there are any knock-on effects we should be aware of.

Thanks!

-Nathaniel

if (Data
    && Data->ComponentName == ComponentName
    && Data->GetDNAAsset() != nullptr)
{
#if WITH_EDITOR
    UDNAAsset* NewDNA = CopyDNAAsset(Data->GetDNAAsset(), SkeletalMesh);
    SkeletalMesh->AddAssetUserData(NewDNA);
#else
    ensureMsgf(SkeletalMesh->GetAssetUserData<UDNAAsset>(), TEXT("SkeletalMesh %s does not already have a DNAAsset!"), *SkeletalMesh->GetName());
#endif // WITH_EDITOR
    SkeletalMesh->AddAssetUserData(NewDNA);

    // A mesh can only have one DNA at a time, so if the CO produced multiple DNA
    // Assets, all but the first will be discarded.
    break;
}

[Attachment Removed]

Steps to Reproduce[Attachment Removed]

Hey there,

We’re actually changing the DNA flow to be a bit simpler in the future, so a majority of this will change. In terms of this code, the DNA is never modified at runtime, so removing the copy entirely is fine. This is a byproduct of the plugin being in an experimental state.

Dustin

[Attachment Removed]

Perfect, thank you Dustin! We’ll remove the copy pathway for runtime.

[Attachment Removed]