- Home /
Slow script recompile time
My scripts compile at least 40+ seconds when I make some changes. Which is ridiculous. Do you have any idea what may cause it?
Both Unity and Project are on same SSD drive
Using only C#
Have less than 5000 lines of code, which is nothing
Have i5 (3.4GHz) and 12GB RAM, so speed should be really fast
Tried deleting Library and Temp folder from project so it reimports stuff, didn`t help
Don`t have McAfee, so it`s scanning cannot slow it down
Please, any idea would be really, really appreciated.
$$anonymous$$ETA: 33 following this question, only 1 upvote. That's Unity answers for you.
Yeah.... $$anonymous$$ore upvotes means more visibility for the Answer, which means this may help and speed up work for many other ppl....
The speed seems to slow down every now and then, I just again, delete library and reimport all assets, but I think it`s the same.
Answer by Wrymnn · Nov 01, 2015 at 09:44 AM
It seems I have fixed the issue.
Not sure what was the cause but:
I added Unity and my Project to Avast exceptions
I went to Assets menu and Re-imported All
My guess is it was antivirus doing some monkey business there and slowing everything. Hope this helps somebody in the future.
Thanks! Turns out, Avast was slowing my compile time down massively as well. After adding an exception for my project and Unity, everything was much faster.
It seems that Crashplan/Dropbox monitoring my files causes compile times to go from 8s to 16s (double). Pausing Dropbox / Sleeping Crashplan seemed to have fixed my compile times.
Answer by eelstork · Oct 31, 2015 at 02:18 PM
As far as I know (though I'm sure somebody will turn up and say the exact opposite) it's recompiling ALL your scripts every time - no incremental compilation. Anyway, there is a strong correlation between the amount of source you have and the compile time, I hope everybody would agree on this point.
Some claim that taking advantage of compilation order you can basically put stable code in a Plugins folder and it won't recompile every time. Last time I tested, inconclusive.
A more proven approach is to build DLLs for your stable code.
Having said that, 'ridiculous' isn't the right word. Compilation time largely depends on your hardware, the amount of code you're compiling, the target platform, the language. Yes, it is recommended to keep compilation times short (seen in textbooks: under 3 minutes). 15 seconds probably falls under the "bear with it" category.
That is the thing, I don`t have a lot of code, and for my PC specs, it just cannot compile that long. It wasn`t before at least. $$anonymous$$aybe there is some compilation settings I don`t know about.
Was it a sudden change, or did it happen at once?
If you're under version control you can compare how long it took say 2 weeks ago, and check how many lines of code you had then (you have a reliable way to measure this, right?). This (looking at previous revisions) may also help you discover the kind of sudden change (added third party code?) that might be slowing down your build.
Or maybe you can compare with another project/source? Is this your FIRST Unity project? If you're making assumptions based on your experience with another platform, these (assumptions) may not apply here.
I don't think 5000 lines of code is negligible when compiling C# with Unity, sorry.
Nor have I heard of any compilation settings that significantly speed up builds. Although I'm not sure whether your question is a duplicate, it's definitely not the first time somebody raise the issue.
Note: if you're not under version control this is a bigger problem than compile time.
Thanks for the help, I really appreciate it :)
Though It seems I have managed to fix this issue, I have written possible source as Answer to this topic.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Unity 2020.3.21f1 running slow 2 Answers
Code execution is slower in Unity then outside of Unity 0 Answers