Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Creating asset takes 15000ms

Discussion in 'General Discussion' started by joshcamas, Nov 15, 2022.

  1. joshcamas

    joshcamas

    Joined:
    Jun 16, 2017
    Posts:
    1,242
    I have a mid-size project with around 25k assets. Using Unity 2020.3. When I duplicate a (very tiny) scriptable object / rename / do anything of the sort, I get a 14500ms spike, and then a few smaller spikes after that. This is really painful. This was also not the case until being forced to switch to AssetDatabaseV2.



    Does anyone else have this issue on a project this size?

    When using Deep Profile, I can see the biggest call is "AssetDatabase.V2.RefreshInternal", with Hotreload taking ~5500ms, and ImportAndPostprocessOutOfDateAssets taking ~1000ms.

    I also can't help but notice "RefreshInternal" is actually happening twice. Is this because duplicating causes two imports (before and after)? If so, OUCH.

    I also see random scriptable assets / prefabs get "reloaded". These are indeed assets in memory, but that seems kind of crazy... if I create a new asset, it causes these assets to be completely reimported, even if there are 0 connections between them and the new asset?
     
    Last edited: Nov 15, 2022
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    1,830
    Though the callstack in the profiler seems to indicate that all of this processing is happening due to a single user command (ie duplicate) I wouldn't rule out an inefficient custom importer or postprocessor or other editor script which may be doing something it shouldn't or simply does more than it needs to.

    Otherwise it could be slow disk access, especially if the project isn't on a (fast) SSD or if the project's path isn't excluded from the virus scanner.
     
    joshcamas likes this.
  3. joshcamas

    joshcamas

    Joined:
    Jun 16, 2017
    Posts:
    1,242
    Yeah, the custom importer/post processor / some weird editor tool is something I'm very wary of, hence this not being put as a bug report yet. The project is on a very fast SSD, and I have no virus scanners active, so neither of those should be an issue.

    Great link btw, I looked through my code to find any spooky Refreshes, I found a few I shouldn't be doing (but these were only called during special events, like a tool that deletes an asset).