asgiref: does the number of sync_to_async calls matter

hi
so i understand that sync_to_async calls of a request cycle all use the same threadpool

but i’m wondering if the number of sync_to_async calls would cause an overhead
so if i manage to reduce 5 calls into 2, will that result in a better performance

Performance can be difficult to measure, and very context specific. I’d highly recommend not worrying about that until you start to suspect that it’s causing you trouble.

That said, the simpler you make your call stack, the easier it’s going to be to work with it.

hi👋🏼
so the reason i’m asking is, i’m developing some async tools for django in the form of a package

now if reducing the number of sync_to_async calls would make a difference in applications, it’s worth it to me to re-write some of django’s stuff

for example, i have a full async version of middlewares, but will that make a difference?
i don’t know if i should merge it or not

Gotcha. Yes, I think that it’s wisest as a library to try to keep sync and async code paths separate as much as possible. That way your consumers get to say what they want and when, and you work within the IO paradigm they prefer.