dpc / mioco.pre-0.9

Scalable, coroutine-based, asynchronous IO handling library for Rust programming language. (aka MIO COroutines).
Mozilla Public License 2.0
457 stars 30 forks source link

Save slab by keeping only blocked io in it. #44

Closed dpc closed 9 years ago

dpc commented 9 years ago

Right now mioco keeps all the even sources in the Slab. But as one coroutine is usually blocked only on one event source, it makes sense to add event sources to the slab only when they are blocked on (EventSourceRefShared::reregister) and remove them when they are not (EventSourceRefShared::unreregister).

The downside is that event sources tokens will have different tokens during their lifetime (harder debugging?) and registering and deregistering things might add some overhead (though it seems tiny enough, to be worth tinier slab (better cache utilization etc)).

dpc commented 9 years ago

Alternatively only Coroutines should be kept in the Slab/HashMap, and Token should be a combination of CorotuineID (24 bits) + EventSourceID (8 bits). This way slab is much smaller.