spawn
and task.spawn
called on a function both create a new coroutine, so there’s no raw performance benefit in that regard. However task.spawn
gives you the option of passing a coroutine instead if you want to manage things more closely yourself including potentially reusing coroutines for better perf.
The task
library is a low level library, it does what you tell it to do. If you use task.spawn
and/or task.wait
to resume 100,000 threads in a frame it will dutifully try to run the 100,000 threads that frame (though there’s no guarantee the client / server in question can actually handle that without lagging / running out of memory).