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

Optimize RefCell. #120

Open dpc opened 8 years ago

dpc commented 8 years ago

Mioco is using Rc<RefCell<...>> a lot.

Rc is cheap and kicks in only during count increase and decrease, butRefCell checks can accumulate to quite a bit overhead (2% CPU time). While very useful, as it proves that there's no aliasing when operating on very interconnected mioco structures (and such aliasing is very easy to introduce by accident), this costs is significant in performance cricial component.

I have an idea of building a RefCell-mimicing type, that does the aliasing testing only in debug mode.

In normal code such optimization is not worth it, but mioco codepaths are very few and generic, doing one debug mode test is enough to prove that there's no aliasing anywhere.

dpc commented 8 years ago

Related: https://github.com/alexcrichton/debug-cell