may icon indicating copy to clipboard operation
may copied to clipboard

can we take the good things from libfringe and put them into may/generator

Open alkis opened this issue 7 years ago • 3 comments

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)

alkis avatar Jan 26 '18 21:01 alkis

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.

Xudong-Huang avatar Jan 27 '18 00:01 Xudong-Huang

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.

Xudong-Huang avatar Feb 22 '18 13:02 Xudong-Huang

for the stable branch use this feature we need to wait rust asm feature got stabled.

Xudong-Huang avatar Jul 09 '18 02:07 Xudong-Huang