I have been looking at optimizing our startup time - from hitting ‘Play’ to starting any of our actual script loads was taking about 12 seconds. After digging through procmon calls on startup, I can see Unity is doing a lot of IO calls on startup. Let’s break them down a bit.
startup load system DLLs
scan full folder tree
load plugin DLLs (A)
scan full folder tree (B)
load system/DX dlls, etc
load dynamic resources from files directly (C) (interleaved)
load static resources from library cache (D) (interleaved)
A) plugin DLLs are loaded in 2b or 4b chunks per IO call
B) seems to be multiple full redundant folder scans
C) files are loaded mostly in 2048b or 7168b chunks, usually full but occasionally sparse
D) files are loaded mostly in 2048b or 7168b chunks, but larger files / faster than dynamic loads
Loading all the system DLLs, Unity DLLs, and plugin DLLs takes about 1-2 seconds. The rest is simply the full resource loading. The dynamic resources load is much slower, and seems to load more full files than sparse loads. A lot of the files are generally quite large, and reading with chunk sizes of 2048b or 7168b means a lot of IO calls per item. The majority of these files are unchanged from run to run, so some caching and timestamp checks could conceivably reduce startup time to almost nothing. There doesn’t really seem to be any actual work that needs doing on two subsequent runs.
(note: tautvydas-zilys mentioned the dynamic resources are loaded as an asset bundle, so it’s probably a pain to change loading there)
Some simple performance improvements might be:
a) increase load chunk size significantly (1-2mb buffer)
b) keep files in memory and file timestamp compare (instant load)
c) read in DLLs in one read instead of 2b/4b chunks (why?)
So the dynamic Resources/ load is much slower, moving most of our assets out of there into static folders reduced startup time to about 2s. I think it might be worth putting a warning on the Resources documentation (ie. this does not scale + loads all for any scene).
I’ve attached procmon logs, just a reminder that editor.log writes is not present because I run with -nolog since log file writes are two calls per BYTE. (Unity Script Compilation - IO analyis - Editor.log does two IO calls per byte written - Unity Engine - Unity Discussions)
Feel free to send me unity source so I can test and compare and write up findings. X)
TL;DR: Avoid using Resources/, it slows down hitting ‘play’ significantly.











