-
Notifications
You must be signed in to change notification settings - Fork 33
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
How does this compare to https://github.com/modesttree/Unity3dAsyncAwaitUtil #16
Comments
From a quick glance at the example API usage and source code, Unity3DAsyncAwaitUtil appears to focus more on utility/convenience without much concern for performance. Most of the await instructions seem to spin up a Coroutine, which isn't something you want to do too often, especially in a next update loop (where a Coroutine would be created every frame). All await instructions are classes, which means they're always heap allocated. Generally, an await instruction is used as a throwaway object – its lifespan doesn't last more than a few seconds or even a frame, and once it's done, it becomes garbage and must be cleaned up by the garbage collector (which can result in noticeable frametime spikes if they build up – recent Unity versions improve this but it's still something to avoid). A few of the per-frame await instructions are statically cached to avoid allocations but you can't do this with configurable ones like WaitForSeconds. UnityAsync's main performance goal is to not cause any unnecessary heap allocations. It does so by implementing all await instructions as structs, which will sit on the stack in a normal async method. Of course, some aspects of async are heavily tied to the Task API and tasks are always heap allocated so there's only so much you can do. For example, awaiting an async method requires the allocation of a Task object, but if you don't need to await it (like starting a Coroutine without caring when it ends), you can make it async void and it probably won't allocate any heap memory. It also runs fast – faster than Unity Coroutines, and allows you to not have to rely on YieldInstructions. Pros:
Cons:
If the concern is compatibility, both libraries are compatible with Unity's IEnumerator coroutines and YieldInstructions. For ease of use, Unity3dAsyncAwaitUtil might have a slight edge due to being simpler and using existing YieldInstruction API. If the concern is performance, UnityAsync is probably the best performing async coroutine library around. I'd give UnityAsync a try – you can use it as little or as much as you wish, so long as that last con doesn't bother you. |
I should add, I wrote the pros and cons and discussion here for you. I'm not so sure about adding it to the README because I don't want to be openly critical of other libraries, but I understand your point and I'll consider adding something to the README to objectively compare with and direct people to a few alternatives. |
Thanks @muckSponge this is really helpfull. Understandable that you don't want to be openly critical of other projects and maybe 'pros/cons' wouldn't be the best way of presenting differences in the README but maybe some of the same information can still be explained. So long as the focus is on technical details then hopefully others can decide how that translates into pros/cons for their specific use cases. Thanks again! |
Is there actually performance benchmarks to back up some of these claims? |
It looks like this project is more up to date and perhaps better maintained than this Unity3dAsyncAwaitUtil project and since I'm currently using Unity3dAsyncAwaitUtil I'd be interested to learn if there are some specific technical pros/cons for each one to help decide whether to use this project instead.
It would be good if the documentation could highlight if there are any key technical differences between this and any other alternatives.
The text was updated successfully, but these errors were encountered: