hybridgroup / rubyserial

FFI Ruby library for RS-232 serial port communication
https://rubygems.org/gems/rubyserial
Other
154 stars 27 forks source link

Release the GVL while calls to C code #39

Closed larskanis closed 6 years ago

larskanis commented 6 years ago

FFI defaults to not release the GVL while calls to C code (in contrast to Fiddle). This blocks other Ruby threads for the time of the call. It also slows simultanous communication down, when running over several TTY's in parallel.

The negative performance impact of releasing the GVL is so small, that it doesn't matter compared to the slowness of RS232. However the positive performance impact when running multiple threads is huge: In my case with 16 devices releasing GVL drops the time for one particular operation from 160 to 23 seconds.

hunterboerner commented 6 years ago

@deadprogram?

deadprogram commented 6 years ago

Seems like the tests are failing due to needing to update how we are obtaining our code coverage?

https://travis-ci.org/hybridgroup/rubyserial/jobs/309030276#L568

Other than that, seems like good work to me.

larskanis commented 6 years ago

The tests pass, when the coverage gem is fixed, but I didn't want to mix this into the same PR.

deadprogram commented 6 years ago

Understood, and makes sense. Any chance of getting a PR to fix coverage, pretty please?

larskanis commented 6 years ago

@deadprogram Will do.

larskanis commented 6 years ago

See PR #40 for the CI update.

deadprogram commented 6 years ago

Thank you very much for this @larskanis now merging.