Skip to content

Instantly share code, notes, and snippets.

@vinoski
Last active November 7, 2017 06:20
Show Gist options
  • Star 14 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save vinoski/4689170 to your computer and use it in GitHub Desktop.
Save vinoski/4689170 to your computer and use it in GitHub Desktop.
How to raise the maximum number of file descriptors when building Erlang/OTP on OS X.

When you build Erlang/OTP on OS X, it unfortunately defaults to handling a maximum of 1024 file descriptors. You can get around this limitation with the right combination of configuration options and manual changes to a generated config file.

First, go into your unpacked Erlang/OTP source directory and run the following command, replacing the value 10000 with whatever value you want for max file descriptors:

perl -i -pe 's/(define\s+FD_SETSIZE\s+)\d+/\1 10000/' erts/config.h.in 

Next, when you run configure in your Erlang/OTP source directory, be sure to include the right CFLAGS setting, as shown below:

CFLAGS='-DREDEFINE_FD_SETSIZE -DFD_SETSIZE=15000 -D_DARWIN_UNLIMITED_SELECT' ./configure --enable-kernel-poll <other options>

For Erlang R15B01, be sure to also include the -O0 option in CFLAGS as well.

Using _DARWIN_UNLIMITED_SELECT forces the use of a different version of select() that won't fail if FD_SETSIZE is exceeded.

Finally, just use make to build and install Erlang/OTP as usual.

You might also have to change some OS X system settings related to maximum numbers of file descriptors as explained in this StackOverflow answer.

@jj1bdx
Copy link

jj1bdx commented Mar 13, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment