build erlang with kqueue support

Lukas Larsson lukas@REDACTED
Tue Nov 16 10:48:44 CET 2021


On Tue, Nov 16, 2021 at 10:30 AM Bogdan Andu <bog495@REDACTED> wrote:

> Great,
>
> I have the following:
>
> 2> erlang:system_info(check_io).
> [[{name,erts_poll},
>   {primary,poll},
>  * {kernel_poll,false},*
>   {memory_size,12920},
>   {total_poll_set_size,2},
>   {lazy_updates,true},
>   {pending_updates,0},
>   {batch_updates,false},
>   {concurrent_updates,false},
>   {fallback,true},
>   {max_fds,512},
>   {active_fds,0},
>   {poll_threads,0}],
>  [{name,erts_poll},
>   {primary,kqueue},
>   *{kernel_poll,kqueue},*
>   {memory_size,56},
>   {total_poll_set_size,1},
>   {lazy_updates,false},
>   {pending_updates,0},
>
>
>   {batch_updates,false},
>
>
>   {concurrent_updates,true},
>
>
>   {fallback,false},
>
>
>   {max_fds,512},
>
>
>   {active_fds,0},
>
>
>   {poll_threads,0}],
>
>
>  [{name,erts_poll},
>   {primary,kqueue},
>   *{kernel_poll,kqueue},*
>   {memory_size,28728},
>   {total_poll_set_size,1},
>   {lazy_updates,false},
>   {pending_updates,0},
>   {batch_updates,false},
>   {concurrent_updates,true},
>   {fallback,false},
>   {max_fds,512},
>   {active_fds,0},
>   {poll_threads,1}]]
> 3>
>
> What means *{kernel_poll,false}* ?
> That poll is not used and kqueue it is used?
>
> Why are three poll entries and why one kernel-poll kqueue entry has
> memory_size 56 and the next has memory_size 28728? Which one is used by
> the emulator?
>

Different OSs need different polling strategies, for OpenBSD (and others, I
can't recall which) there are by default 3 pollsets used.

1) The first pollset is what is called the fallback pollset and it is used
for any FD that cannot be polled by kqueue. I think that the stdin/stdout
fds end up here and possibly some others.
2) The main pollset used by the poll-thread for most I/O polling. This is
why this pollset is larger.
3) An optimized pollset where the read side of any fd that uses the
`{active,true}` pattern is placed. Mainly this is used for distribution
sockets, but works for any other fd as well that follows this pattern.


> And how can I customize the parameters like max_fds, total_poll_set_size,
> memory_size?
>

Max fds is taken from `ulimit -n` of the current user. The other values are
just statistics about the current usage.


> And how does these parameters impact the performance of busy erlang node
> like say,
> very high traffic tcp/ip/ssl server?
>

They don't. These values are meant for debugging the system, not optimizing
it. If you are interested in optimizing you may want to read this blog
post: https://www.erlang.org/blog/io-polling/.

However, from the I/O polling point of view things are quite optimal in the
default setting. So I doubt that you can gain much by tweaking the
different options available.


>
> Thank you,
>
>
> On Tue, Nov 16, 2021 at 11:07 AM Lukas Larsson <lukas@REDACTED> wrote:
>
>> On Tue, Nov 16, 2021 at 9:59 AM Bogdan Andu <bog495@REDACTED> wrote:
>>
>>> Hi Lukas,
>>>
>>> I didn't; find any documentation related to that.
>>>
>>
>> A pr improving the documentation would be much appreciated!
>>
>>
>>>
>>> Anyway,
>>>
>>> $ erl
>>> Erlang/OTP 24 [erts-12.1.4] [source] [64-bit] [smp:4:4] [ds:4:4:10]
>>> [async-threads:1]
>>>
>>> Eshell V12.1.4  (abort with ^G)
>>> 1> erlang:system_info(kernel_poll).
>>> true
>>> 2>
>>>
>>> I guess I have kernel poll support for my erlang servers.
>>>
>>> How can one tell if it is 'kqueue' or 'poll' type of kernel poll?
>>>
>>> Because OpenBSD has also poll which is not great
>>>
>>> Is there any erlang system information function that shows
>>> exactly that?
>>>
>>
>> If you run `erlang:system_info(check_io)` you will get information about
>> the I/O checking sub-system which should include information about which
>> mechanism is used.
>>
>>
>>>
>>> Thank you
>>>
>>>
>>>
>>> On Tue, Nov 16, 2021 at 10:53 AM Lukas Larsson <lukas@REDACTED> wrote:
>>> >
>>> > Hello!
>>> >
>>> > The banner about kernel-poll was removed from the erlang start some
>>> releases ago. So to check if you have kernel poll support you need to call
>>> `erlang:system_info(kernel_poll)`. If it returns `true` then you have
>>> kernel-poll support.
>>> >
>>> > Lukas
>>> >
>>> > On Tue, Nov 16, 2021 at 9:47 AM Bogdan Andu <bog495@REDACTED> wrote:
>>> >>
>>> >> Hello,
>>> >>
>>> >> I have an OpenBSD 6.8 amd64 machine and
>>> >> I would like to compile Erlang 24 with kqueue support
>>> >> such that I want erl to show me this:
>>> >>
>>> >> $erl
>>> >> ........................ [kernel-poll]
>>> >>
>>> >> I understand that this is a compile time option
>>> >> and not anymore a runtime selectable option tru + K true
>>> >> switch
>>> >>
>>> >> I tried the following configure options with no success:
>>> >> ./configure --prefix=/usr/local/erlang24.1.4
>>> >> --with-ssl=/usr/local/openssl/1.1.1l --enable-dynamic-ssl-lib
>>> >> --with-ssl-rpath=/usr/local/openssl/1.1.1l/lib --without-javac
>>> >> --enable-threads --enable-kernel-poll --disable-hipe
>>> >>
>>> >> With openbsd patches (+./otp_build update_configure)
>>> >> and without patches the result is the same:
>>> >> no kernel-poll flag present - meaning that kernel polling with kqueue
>>> >> is not available to that erlang emulator.
>>> >>
>>> >> Please advice me how to build erlang 24 with kqueue support.
>>> >>
>>> >> I have an Openbsd 5.4 with erlang 19 that does has kernell-poll flag
>>> >>
>>> >> $ erl +Ktrue
>>> >> Erlang/OTP 19 [erts-8.1] [source] [64-bit] [smp:2:2]
>>> >> [async-threads:10] [kernel-poll:true]
>>> >>
>>> >> Eshell V8.1  (abort with ^G)
>>> >>
>>> >>
>>> >> p.s.
>>> >> building erlang 24 against openssl 1.1.1 for tlsv3 support wasn't
>>> >> a pleasant experience. The configuration script links against
>>> >> system libressl  openssl library, instead of --with-ssl option given
>>> >> to ./configure.
>>> >> So I had to alter manually crypto ./configure and Makefile files .
>>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20211116/557376aa/attachment.htm>


More information about the erlang-questions mailing list