From: samuel@... Date: 2021-06-30T04:29:44+00:00 Subject: [ruby-core:104445] [Ruby master Feature#18015] Replace copy coroutine with pthread implementation. Issue #18015 has been updated by ioquatix (Samuel Williams). Pull request: https://github.com/ruby/ruby/pull/4606 ---------------------------------------- Feature #18015: Replace copy coroutine with pthread implementation. https://bugs.ruby-lang.org/issues/18015#change-92699 * Author: ioquatix (Samuel Williams) * Status: Open * Priority: Normal * Assignee: ioquatix (Samuel Williams) ---------------------------------------- The copy coroutine is unique in that it uses a private stack area. It is also tricky to implement as it uses setjmp/longjmp to update the stack & instruction pointer. Because of this, pointers to stack allocated data are only valid while the fiber is running, and this makes implementation tricky for any code which uses stack allocated structs. Previously we introduced some macros for dealing with this - copy coroutines fall back to malloc/free rather than using stack locals, but the chance if this causing problems is very high. In addition, rb_protect prevents us from switching fibers, which also prevents the fiber scheduler from operating within this context. We propose to remove the copy coroutine implementation and replace it with a pthread-based cooperative scheduled implementation. This implementation uses one native thread per fiber, but only allows one of them to execute at a time using a mutex. This approach should be more consistent with the other native implementations and allow us to simplify a number of implementation details. -- https://bugs.ruby-lang.org/ Unsubscribe: