python / asyncio

asyncio historical repository
https://docs.python.org/3/library/asyncio.html
1.04k stars 177 forks source link

Why are streams slower than 'standard' protocol implementations? #412

Closed ghost closed 8 years ago

ghost commented 8 years ago

Streams seem to be slower. Why is that so?

1st1 commented 8 years ago

I've applied some optimizations to uvloop since that blog post which made streams 20-30% faster.

They are slower than callback/protocol implementation because of an extra layer of abstraction. async/await, Tasks and Futures introduce some overhead. That said, I think it's possible to remove a lot of that overhead by implementing Futures/Tasks/Streams in C, which we're slowly doing now.

mayflaver commented 8 years ago

I think if it's possible to remove a lot of that overhead by implementing Futures/Tasks/Streams when parsing protocol and then apply the protocol result async.

something like https://github.com/mayflaver/sora

asvetlov commented 8 years ago

@mayflaver would you explain in details what's the difference between current implementation and your idea?

mayflaver commented 8 years ago

@asvetlov more yield trigger more overhead

ghost commented 8 years ago

Thanks a lot for your explanation! I guess this can be closed now