-
Notifications
You must be signed in to change notification settings - Fork 347
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FR] Optimize XmlDependencies.IsDependenciesFile for Performance #601
Comments
This issue does not seem to follow the issue template. Make sure you provide all the required information. |
This simpler string manipulation checks the same logic as before but much faster in the context of a large project. If the OnPostprocessAllAssets callback is invoked multiple times with thousands of files, as can happen with non-trivial Unity projects, the regex call becomes quite expensive. For profiling data see: googlesamples#601
I see your point. I think the key issue is that iOS Resolver is trying to scan through every changed asset and run a regex against their path. This is definitely not good if you have a large project and modify many files at the same time. You code actually changed the logic: Since the searching so relatively simple, I think it can do
We are currently working on other EDM4U issue. If you like to, I would encourage you to send us an PR. Shawn |
Thanks for your feedback, Shawn! :) I've opened a PR: #602 Sorry about the code sample, I didn't think it through or test it, but in my PR I created a test class to make sure the updated logic is the same as before and also tested in the production project in which my company is using the Google plugin. I've inserted the changes so that new public API stays compatible with previous versions for now. I might need some help with releasing the correct build artifacts though, not sure which one I need to commit. Best, |
This simpler string manipulation checks the same logic as before but much faster in the context of a large project. If the OnPostprocessAllAssets callback is invoked multiple times with thousands of files, as can happen with non-trivial Unity projects, the regex call becomes quite expensive. For profiling data see: googlesamples#601
Feature proposal
I've observed a significant performance slowdown in the Unity Editor when using Android Resolver and iOS Resolver in a large project with numerous assets:
As seen in the profiler screenshot, the XmlDependencies.IsDependenciesFile method takes 30 seconds to execute in my current project setup. While reducing the calls to this method by refreshing the Unity AssetDatabase less frequently could be a solution, it may not always be feasible due to certain project limitations. Instead, optimizing this method seems more practical.
The performance bottleneck appears to be the regex pattern in the following code snippet:
A possible optimization involves replacing the regex pattern with simpler string manipulation methods like this example (untested):
However, PlayServicesResolver also uses fileRegularExpressions to add additional patterns. I'm unsure how this can be easily accommodated, but I propose the following potential improvements:
I would be happy to investigate this issue myself and test changes in my project. Any feedback is greatly appreciated!
The text was updated successfully, but these errors were encountered: