[erlang-questions] max fds for epoll incorrectly reduced to FD_SETSIZE

Steve Vinoski vinoski@REDACTED
Mon Feb 23 23:41:43 CET 2009


On 2/23/09, Steve Vinoski <vinoski@REDACTED> wrote:
> On 2/23/09, Bjorn Gustavsson <bgustavsson@REDACTED> wrote:
>  > On Sat, Feb 21, 2009 at 8:16 PM, Steve Vinoski <vinoski@REDACTED> wrote:
>  >  > Since kernel poll is not on by default, select() is used as the
>  >  > fallback/default, and the following code from the erts_poll_init()
>  >  > function in erts/emulator/sys/common/erl_poll.c limits the max fds to
>  >  > FD_SETSIZE:
>  >
>  > Are you sure that select() is used as a fallback on Linux? On systems that have
>  >  a poll() that works for any type of file descriptor, poll() is supposed to be
>  >  used. (On Mac OS X, poll() does not work for devices, so we are forced to use
>  >  select() as a fallback.)
>
>
> Hi Bjorn, thanks for your response, and yes, that's a very good
>  question. I went back and thoroughly checked my normal Erlang builds
>  on Linux and sure enough, poll() is in effect. The build causing the
>  trouble I described in my original post is a slight cross-compilation
>  (i.e., compiling on one Linux/gcc combo for a different Linux/gcc
>  combo), so I suspect what might be happening is that the C code used
>  to determine whether poll works or not, which I just found thanks to
>  your question, is failing because of the cross-compile. I'll dig into
>  this theory further and let you know. I appreciate the pointer.

Yep, it's as plain as day once you know where to look. In the
configure script generated from erts/configure.in, the test for
working poll first checks to see if we're cross-compiling, and if so,
it unconditionally sets the "poll_works" variable to false. That's the
source of the problem I'm seeing.

Given how critical this is to being able to cross-compile a scalable
runtime, I think there has to be a way to assert to configure that it
can just assume poll works. One way to do this is to allow for setting
a environment variable, let's call it ASSERT_WORKING_POLL, while
running configure. Here's a patch to erts/configure.in to allow that:

 *** erts/configure.in~	Tue Nov  4 05:51:24 2008
 --- erts/configure.in	Mon Feb 23 16:48:16 2009
 ***************
 *** 2541,2547 ****
     exit(0);
   #endif
   }
 ! ], poll_works=true, poll_works=false, poll_works=false)
   case $poll_works in
   true)
         AC_DEFINE(ERTS_USE_POLL, 1, [Define if poll() should be used
instead of select()])
 --- 2541,2547 ----
     exit(0);
   #endif
   }
 ! ], poll_works=true, poll_works=false,
poll_works=${ASSERT_WORKING_POLL:-false})
   case $poll_works in
   true)
         AC_DEFINE(ERTS_USE_POLL, 1, [Define if poll() should be used
instead of select()])

 ---

This functionality is identical to the previous functionality when
ASSERT_WORKING_POLL isn't set or is set to false. Setting
ASSERT_WORKING_POLL=true as an environment variable for configure
forces it to assume that poll works.

--steve



More information about the erlang-questions mailing list