-
Notifications
You must be signed in to change notification settings - Fork 12
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
Service Provider Is Very Slow #3
Comments
Hey @MannikJ, Thanks for the thorough report, and sorry I haven't gotten back to you on #2 yet. I've been super busy, so I probably won't have a chance to address it for a while. Starting at the end first, there are two reasons I chose to use a singleton for API classes in single-seller mode:
I think these suggestions of yours are the best options for fixing a) the issue of tests being slow, and b) keeping things running fast in production:
If speed is still an issue after those fixes, manually listing all the API classes instead of auto-detecting them would be the next step, I think. The list of classes changes infrequently enough that I don't think that it would be a big deal to update them occasionally. A PR would be much appreciated! |
Closed by #4. |
The code above to find all the api classes runs very slowly. It takes about 0.5 seconds on my machine each time it is run. Since the service provider is created at every framework boot, this has a huge performance impact. In fact we noticed that our test suite was slowed down drastically - it took basically 5 times longer only because the above piece of code. Not to mention that the service provider also tries to obtain auth tokens every time it runs like discussed in another issue (#2 ). This impact is not even factored it.
I can think of some quick fixes to improve the performance of this service provider related to class loading by also preparing the setup to be a bit more flexible for later improvements:
The above changes would only speed up the tests by deactivating the class registration completely. In production, we can not use a steamroller approach like this, because the binding is actually needed, so that the app knows how to resolve these classes with their correct configuration.
To reduce the performance impact in production we could:
I am not exactly sure why singleton was chosen for this matter, but in fact when binding something as a singleton, the app will immediately call the resolve callback to make sure the instance exists. I guess using normal binding should work just as well and maybe behave more like the user would expect. It would be more a on-demand creation than creating all the objects even if they are not used at all. Of course each call would resolve it's own instance which could potentially lead to issues, but I don't think it actually will.
If my suggestions feel valid to you, I could prepare a pull request. I'm looking forward to hear your thoughts on my ideas.
The text was updated successfully, but these errors were encountered: