[ruby-core:81047] Re: [ruby-cvs:65407] normal:r58236 (trunk): thread.c: comments on M:N threading [ci skip]

From: Eric Wong <normalperson@...>
Date: 2017-05-09 05:12:23 UTC
List: ruby-core #81047
SASADA Koichi <ko1@atdot.net> wrote:
> On 2017/05/09 12:38, Eric Wong wrote:
> > 100 epoll FDs is a waste of FDs; especially since it is common
> > to have a 1024 FD limit.  I already feel bad about timer thread
> > taking up two FDs; but maybe epoll/kevent can cut reduce that.
> 
> 1024 soft limit and 4096 hard limit is an issue. However, if we employ
> 
> > I can easily imagine Ruby doing 100 native threads in one process
> > (8 cores, 10-20 rotational disks, 2 SSD), but 20000-30000 fibers.
> 
> 20000-30000 fibers, it is also problem if they have corresponding fds.
> So that I think people increase this limit upto 65K, don't?

Yes, for people that run 20000-30000 fibers maybe it is not a
problem to have 100 epoll FD...

However, for existing apps like puma, webrick and net/http-based
scripts: they can spawn dozens/hundreds of threads and only use
one socket per thread.  It is a waste to use epoll/kqueue to
watch a few number of FD per thread (ppoll is more appropriate
for watching a single FD).

On the contrary; software like nginx and cmogstored watch
thousands of FDs with a single epoll|kqueue FD.

> > In the kernel, every "struct eventpoll" + "struct file" in
> > Linux is at least 400 bytes of unswappable kernel memory.
> 
> 400B * 100 = 40KB. Is it problem? I have no knowledge to evaluate this
> size (10 pages seems not so small, I guess).

I'd rather not use that much memory and save whereever possible.

> > OK, I can rename my work-in-progress patch with
> > s/rb_thread_context_t/rb_execution_context_t/ and commit
> > later tonight.
> 
> Ah, that was my plan and I'm not sure what is suitable name (always I
> consumes long time for naming problem). But if you don't feel weird,
> please use execution_context (ec).

OK, I committed as r58614

> Do you want to commit your patch into trunk immediately and change them
> for "(2-1: extend Fiber)" later?  Another way is to make "(2-1: extend
> Fiber)" first (in another branch or git repository) and commit it. The
> latter can reduce total patch size.

OK, I will work on implementing epoll/kqueue support late this
week or weekend.  I will also keep a select() fallback for
portability to systems w/o epoll|kqueue.

Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>

In This Thread