2020.2: Deleting assets inside Unity is significantly slower than deleting them via Windows Explorer

During the 2019.3 beta phase I reported that deleting assets inside Unity is significantly slower than deleting them via Windows Explorer.

Today I tested whether the same holds true with Unity 2020.2.0a21.

Results

  • Windows Explorer = 2 seconds
  • Unity 2020.2.0a21 = 6 seconds
  • Unity 2019.3.0a8 = 12 seconds (taken from this video )

Conclusion
Deleting assets performance improved significantly compared to Unity 2019.3. However, it continues to be significantly slower than deleting the files in Windows Explorer as well.

Thumbs up for the improvement compared against 2019.3, thumbs down for still being slower than Windows Explorer. :slight_smile:

6259046–690347–AssetImport_4.6.zip (15.2 KB)

4 Likes

Does the windows explorer measurement include the time it takes for Unity to import assets when you switch back to Unity after deleting in Explorer?

1 Like

Nope, it does not. According to my other test , it would be +1.5 secs worse case for the asset database refresh.

That’s kind of comparing apples to oranges - AssetDatabase.Refresh is the top level call for many different sorts of work Unity does to synchronize its internal asset database with your files. The actual work will differ depending on what’s changed (if no files have changed, the time taken by Refresh may be drastically different from if a file was added, which may take a different amount of time compared to if a file has been deleted).

Neither your windows explorer measurement nor your other test you linked includes the time taken by Unity to refresh its asset database after a file is deleted, whereas the measurement where you delete a file through Unity’s interface does.

The comparison numbers only tell a small part of the story and are kind of misleading without including the refresh time after deleting an asset through Explorer - having that number separate from the Explorer number (e.g. “2 seconds in Explorer, 3 seconds in Refresh” or whatever) makes sense though.

1 Like

That’s a database refresh for creation, though.

I get that deleting the asset in Unity has to take longer than in Explorer, as Unity also has info about the asset in the library that has to be cleaned out. If the performance is that much worse, it might be that the cleanup is happening one-by-one instead of all at once. Or something like that.

2 Likes

I just want to add some info about this case: we looked into it and we know why it’s slower.

We issue some commands to the OS once per file, such as copies and deletes. But on some OSs, there are functions to allow asking for multiple files to be deleted/copied all in one command. We don’t make use of this (but we should!)

This accounts for the huge time difference between doing the operation in Unity vs Windows Explorer.

It would be a bit of a rewrite to fix this in Unity, which is why it’s not been fixed yet, but hopefully it will be done at some point.

The AssetDatabase.Refresh stuff is also relevant, but it’s only a small factor compared to the issue of submitting the commands one file at a time.

12 Likes

Just upgraded a project to 2022.2.12 and deleting a single file now takes a ridiculously long time - I hadn’t noticed this until upgrading from the 21 LTS to 22.

So…things are not getting better on this front it doesn’t seem ;{

Even worse on 2022.3. Deleting a simple file or even an empty folder sometimes freezes the editor up for 20 seconds.

Yes, I have the same issue with 2022.3 and it’s a fast PC that I have where the project is stored on a SSD.

I believe those long freezes are mostly the first time I press Delete or after I wakeup the PC from sleep.

1 Like

It’s annoying to the point it’s faster to open a file in explorer and delete it there alongside its meta when I know it’s not a crucial file.

Same here, first deletion is slow then following ones are fast. 2022.3.8f1.

Bump. It seems to get increasingly worse as projects grow. Very annoying

Deleting many trees (+1000), just makes unity hang forever. The fix is, to create a new Scene, copy all objects except the ones you want, then delete old scene… still in: 2023.3.
And also indeed, deleting an empty! folder, just freezes unity.