Wyn v1.8: Green Threads and Coroutines
February 2026
v1.8 is the biggest release since v1.0. The headline feature is green threads — stackful coroutines with an M:N work-stealing scheduler.
spawn/await
fn fetch(url: string) -> string {
return Http.get(url)
}
var f1 = spawn fetch("http://api.example.com/users")
var f2 = spawn fetch("http://api.example.com/posts")
var users = await f1
var posts = await f2Each spawn creates a coroutine with an 8MB virtual stack (only ~4-8KB physical for simple tasks). The scheduler distributes work across OS threads. I/O operations automatically yield the coroutine and resume when data is ready.
Channels
var ch = Task.channel(10)
spawn fn() {
for i in 0..100 {
Task.send(ch, i)
}
}
for i in 0..100 {
var val = Task.recv(ch)
}Channels are buffered and coroutine-aware. Sending to a full channel yields. Receiving from an empty channel yields.
Performance
Benchmarked on Apple M4 (wyn build with clang -O2):
- fib(35): ~120ms
- Sequential spawn+await: ~20 μs/op
- Concurrent batch (100): ~15 μs/op
- Max concurrent spawns: ~5-10K (limited by 8MB virtual per coroutine)
- Binary size: ~50KB
Wyn's spawn overhead (~20μs) is slower than Go goroutines (~1μs) but faster than Python asyncio. For typical workloads (web servers, CLI tools, concurrent I/O), it's fast enough.
I/O event loop
The runtime includes a kqueue (macOS) / epoll (Linux) event loop. When a coroutine does a blocking I/O operation, it parks itself and the scheduler picks up other work. When the I/O completes, the coroutine resumes.