Can I call async functions for everything?
Is there a performance penalty for always calling async functions? What happens exactly, is a thread always spun up when I call an async function?
@redcurry hi
Is there a performance penalty for always calling async functions? What happens exactly, is a thread always spun up when I call an async function?
Of course yes, you should use async version for heavy computations to avoid blocking UI, for simple computations, synchronous functions are preferred. I have not benchmarked it but I think it's acceptable if you want to keep UI responsive.
Basically, asynchronous functions are implemented via NativeCallable.listener, which is implemented with SendPort and ReceivePort across different isolates, thus extra cost is introduced.
OK, that makes sense, thank you. I started by using async in places where I thought was heavy computation, but when I benchmark it, the async version is slower for many of these functions.