From: Eric Wong Date: 2017-05-08T06:36:33+00:00 Subject: [ruby-core:81035] Re: [ruby-cvs:65407] normal:r58236 (trunk): thread.c: comments on M:N threading [ci skip] SASADA Koichi wrote: > On 2017/05/08 12:01, Eric Wong wrote: > >>> . > >> `Fiber.scheduler.add_auto_fiber{ ... }` (naming is not fixed) (operation > >> for scheduler) is my first idea. > > Too verbose, I think. If I want to type more, I would not be > > using Ruby :) How about adding kwarg to Fiber.new? > > This design introduce new aspect: can we make schedulers per a thread? Maybe; if we can avoid GVL and introduce more parallelism. However, I think having one epoll/kqueue FD is better for a whole process; maybe one epoll/kqueue per-core (not per-thread) at maximum. I can easily imagine Ruby doing 100 native threads in one process (8 cores, 10-20 rotational disks, 2 SSD), but 20000-30000 fibers. Side note: First, I would like to make fibers smaller. Right now rb_fiber_t stores all of the rb_thread_t struct, but not all fields get used. I started to work on splitting out to a new struct rb_thread_context_t earlier: https://80x24.org/spew/20170508040753.24975-1-e@80x24.org/raw (incomplete, I will work on it some more tomorrow) The end goal is to avoid storing all of rb_thread_t inside rb_context_t/rb_fiber_t; and only store rb_thread_context_t. That should reduce memory overhead and maybe make switching faster. Also, I think we can use uint32_t (or even uint16_t * 4096) to store stack sizes. Using 64-bit size_t represent a stack size is excessive. Unsubscribe: