Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
1
Question by milchoDH · Oct 01, 2018 at 12:58 AM · optimizationslowplaymodeplay mode

Going into Play Mode is slow(er than we'd like)

As our project grows we're experiencing higher and higher overhead on the compile and going-into-play-mode actions. I've been doing some marginal profiles and testing recently to try and narrow down on the culprits. I did manage to get going-into-play-mode time down quite a bit, but I feel there should be more room for improvement.


For reference, it takes me between 7-8 seconds to go into play mode with:
i7 6700k
32GB RAM
M.2 1400MB/s SSD
GTX 970 (largely irrelevant for this I assume)


I also have a laptop, which takes around 10 seconds to go into play mode with:
i7-7700HQ
16GB RAM
SSD
GTX 1070MQ


There are a few things in the profiler that I am not sure I understand. Let's start with a non-deep profile on the laptop: Non-Deep profile


This is the first thing that caught my eye when profiling - a big chunk (~5) of the first 9 seconds are spent in ReloadAssembly (1/4th of which is in executing the OnLoadAttribute)


To get more info let's look at the deep profile: Deep-Profile


The first strange thing on this snapshot is that the [Time ms] are not shown in the majority of the stack trace. I assume that's either a limitation of the profiler or a bug. In either case, that's not terribly useful as an absolute metric in deep profile - it's mainly useful to locate the bottleneck. I used the GC Aloc instead, which works in this case.


Looking at this stack trace I also feel a bit worried - you can see CreateDefaultEncoding() opening a FileStream, which eventually loads in all Editor Assemblies. Let's not go into that though - just looking at the bottleneck, it seems that RegisterAssembly() is really what eventually ends up eating a lot of that time (by using some good-old reflection) since it's called 331 times.


This is no surprise, but I am trying to make things run faster, so I ask if anyone has any ideas on how to improve this situation? For instance, why is the profile detecting 2 calls to AssemblyUtilities.Reload()? I put a breakpoint in that method and was able to extract a list of all of our assemblies, a total of 166 - this number seems quite high, this is how they are spread out:
1. 42% - UnityEngine
2. 9% - UnityEditor
3. 49% - Other


Even though the numbers here are pretty high (50% of all of the assemblies are Unity's - about 85 in total), you would think that going-into-play-mode in an empty project will have a similar overhead in the same path - but no, I don't even see that path on the profiler when I run it on one of my minimal demo projects: Demo-Project The [Time ms] looks similar, but the cause seems to be different. I can't tell if that's a bug in the profiler showing me the same thing or I am missing something obvious.


Am I going crazy here? I am just trying to find a way to iterate faster while in the editor.

Comment
Add comment · Show 4
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image NoDumbQuestion · Oct 01, 2018 at 02:18 AM 0
Share

You mean unity re-compile each time you enter play mode?

And you have 166 assembly is quite of weird. Even with new assembly def, you not suppose to have made that many and plugins from unity not suppose to be recompile.

I am not sure, I always suppose unity only have 1 main assembly in Assets folder

avatar image milchoDH NoDumbQuestion · Oct 01, 2018 at 08:31 AM 0
Share

It doesn't recompile - On pressing Play, Unity unloads and reloads the Domain (in a separate $$anonymous$$ono instance according to this post - https://forum.unity.com/threads/speeding-up-monomanager-reloadassembly.274133/), which means all C# Assemblies need to get loaded again.


We're barely using assembly defs (only for some of our plugins), which we have quite a few of. A full list of all of our assemblies you can see here: https://forum.unity.com/threads/going-into-play-mode-is-slow-er-than-wed-like.563083/. It is a high number, but if you create a new project and do System.AppDomain.CurrentDomain.GetAssemblies(), you get >100 assemblies from the get-go.

avatar image NoDumbQuestion milchoDH · Oct 01, 2018 at 08:37 AM 1
Share

I found another forum about this bugs here:

https://forum.unity.com/threads/unity-entering-play-mode-slowly-due-to-spending-10-20-seconds-in-reloadassemblies.471683/

it seem like this bugs is related to lots of stuff, you should ask unity dev directly for specific help

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by hydrix · Oct 11, 2018 at 11:34 PM

Try looking into Editor.log

 macOS    ~/Library/Logs/Unity/Editor.log
 Windows    C:\Users\username\AppData\Local\Unity\Editor\Editor.log

There might be an error or something strange happening. I found once the Unity Editor uses D://Temp which I already use for other purposes, and it was bogging down creating some data for every file I had in there already (thousands of files). Another problem I had was when my MapMagic was corrupted during a crash. I had to remove each object one by one until it stopped freezing, and the culprit was the MapMagic terrain. Once I recreated it, it was fine. Try creating a brand new scene and test that. Try creating a brand new project and test that.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

161 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

EnterPlayMode very slow because of AttemptInitializeXRSDKOnLoad 0 Answers

Extremely Low FPS in Editor, smooth in Build. how to fix? 3 Answers

Reload Assemblies making enterplaymode take long 4 Answers

why do i keep getting compiler errors even though my script has no errors? 2 Answers

Why does input only work after a build? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges