Using undocumented features (Was: stop process migration)

Rickard Green rickard@REDACTED
Sat Feb 22 22:49:46 CET 2020


On Fri, Feb 21, 2020 at 8:59 PM Karl Velicka <karolis.velicka@REDACTED>
wrote:

> Hi,
>
> (I'm reading your question as "how to pin an Erlang process to a CPU
> _core_)
>
> There is an option to erlang:spawn_opt - {scheduler, SchedNum} to pin a
> process to a specific scheduler in the VM. However, this option is
> undocumented so it's probably exposed on "caveat emptor" basis. We get the
> possible scheduler numbers by doing lists:seq(1,
> erlang:system_info(schedulers_online)) and we've been using the flag in OTP
> versions 20-22.
>
>
This feature was introduced to simplify our testing. It does *not* have
product quality and may cause major problems for the system as a whole.
Especially if lots of processes are pinned to specific schedulers.

In general, using undocumented features or API:s may cause you major
problems. They may change behavior or be removed at any time without any
notice from us what so ever. You may also not fully understand the effects
of using them. Some internal API:s can cause very strange side effects if
not used properly. That is, I strongly discourage you from using any
undocumented stuff that exist in OTP.

A much better approach is to ask us for a new feature or to document an
existing feature at <https://bugs.erlang.org> or make a pull request at <
https://github.com/erlang/otp>. If/when it gets implemented and taken into
OTP of course depends on what it is, how we prioritize it, etc.

Before anyone asks us to document the 'scheduler' option of spawn_opt(), I
can answer you *no* straight away. At least not without having solved the
issues that it can cause, and currently we do not have the time to do that.

The scheduler itself is just a thread from the perspective of the OS so I
> assume it shouldn't be difficult to pin to a core.
>
>
See <http://erlang.org/doc/man/erl.html#+sbt> on how to bind schedulers to
logical processors.


> All the best,
> Karl
>
> On Thu, 20 Feb 2020 at 17:05, Satish Patel <satish.txt@REDACTED> wrote:
>
>> Folks,
>>
>> Can i tell erlang to not load-balance process or migrate process to
>> different CPU?
>>
>
Regards,
Rickard
-- 
Rickard Green, Erlang/OTP, Ericsson AB
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20200222/7398187b/attachment.htm>


More information about the erlang-questions mailing list