You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to build a system with coroutines, but performance is my concern. My question is how to design the system: should I create a fixed number of coroutines at the beginning and keep reusing them, or can I simplify my design: create a coroutines, once it is done destroy it and create another one. I would prefer the second solution unless it is slower.
The text was updated successfully, but these errors were encountered:
should I create a fixed number of coroutines at the beginning and keep reusing them, or can I simplify my design: create a coroutines, once it is done destroy it and create another one
In most scenarios, there is not very much performance difference between these two choices. Strictly speaking, the former would be slightly faster than the latter because the former is more cache-friendly and some memory allocation and release operations are reduced. We can use tcmalloc to mitigate such differences.
But if the memory itself is the bottleneck of your system, then the former one is probably the better choice.
Thanks for the answer. One more question. is it possible to create a system with e.g. one main co and several slave co, such as, when aco_yield is called, the task doesn't switch to the main co, but to the next co in the ring
Currently, I have this
slave1 -> main co -> slave2 -> main co -> slave3 -> ... slave8 ->main co -> slave1
But what I want is
slave1 -> slave2 -> slave3 -> slave4 -> ... -> slave8 -> main co -> slave1
Hi!
I want to build a system with coroutines, but performance is my concern. My question is how to design the system: should I create a fixed number of coroutines at the beginning and keep reusing them, or can I simplify my design: create a coroutines, once it is done destroy it and create another one. I would prefer the second solution unless it is slower.
The text was updated successfully, but these errors were encountered: