may
may copied to clipboard
can we take the good things from libfringe and put them into may/generator
https://github.com/edef1c/libfringe
This crate has rather nice approach to switching contexts:
- instead of saving all callee registers it issues asm to denote they are clobbered. Then the compiler saves only the registers that need saving
- at least on unix it stitches back the stack so stack traces look legible
- performance seems unparalleled: 3ns per context switch (granted only when a few registers are saved)
That's an awesome good idea! Currently the context switch would cost about 30ns on unix, this would improve the performance significantly. We need to integrate it in the generator library. I also want grab some good things from parking_lot about the thread wakeup, but this should be another issue.
I think this is done in the nightly build. just include following config in your application's Cargo.toml
[replace]
"generator:0.6.5" = { git = "https://github.com/Xudong-Huang/generator-rs.git", branch = "libfringe" }
this should replace all the dependent generator library by using the libfringe branch. Though the generator context switch is improved 2 times faster than the master branch, but it's not the critical bottleneck for coroutine tasks, so I didn't see much improvement for the heavy io test.
for the stable branch use this feature we need to wait rust asm feature got stabled.