Closed tjad closed 3 years ago
It is not possible to permanently free the mxnet engine from the GVL using Ruby 2.x. Making use of rb_thread_call_without_gvl
or rb_thread_call_without_gvl2
is a temporary effect that only lasts under execution of these functions. Applying this on imperative_invoke
is fruitless as this only queues and potentially awaits the completion of execution. The mxnet threaded engine is required to be allowed to run in parallel.
For those seeking full parallel capability with mxnet engine, ruby 3.x will be required. refer to #53
When multiple libraries that rely heavily on CPU time are being utilised within Ruby such as MXNet, they contend for CPU time. MXNet is designed for parallel processing and hence it does not make sense to keep the engine bound within the GVL. For best performance the mxnet engine should be initialised outside the context of the Ruby GVL. We rely on the incubator MXNet team to do their parallel processing with threads correctly.