What is Erlang OTP

Erlang / OTP 20 published: A round number

The recently released Erlang release bears the proud version number 20. With such high numbers, no more revolution is to be expected. Rather, the team around Erlang / OTP continuously strives for higher quality and step-by-step improvement. So also with this version. One of the most important is under the hood.

Erlang / OTP is intended as a near realtime platform: Schedulers distribute the lightweight processes to the virtual cores. The changes between the tasks are carried out with very low latency in the lower millisecond range. As long as the code is in the pure Erlang world, it works wonderfully, but is not sufficient for a complete system.

Contact with the outside world

In addition to the pure Erlang libraries, the environment knows the so-called built-in functions (BIF), which are implemented natively and which the runtime environment provides. In addition, there are the Natively Implemented Functions (NIF), in which native C functions can be used through Erlang / OTP. However, these do not adhere to the clean scheduler behavior of the Erlang processes. In the worst case, they block the scheduler for several hundred milliseconds. This, in turn, can lead to a scheduler collapse that has to stop working.

The makers, however, have found a solution in the current release that consists of two special thread groups, one for I / O and one for CPU-related tasks. As dirty marked NIFs are now assigned to the appropriate group for them. Without affecting the work of the regular schedulers, they join the queue of outstanding function calls. While the calling process is blocked, the corresponding scheduler remains free for other processes. After the appropriate resource allocation, the NIFs are then executed in their respective thread group.

Your status changes from schedule_dirty_io_nif respectively schedule_dirty_cpu_nif to execute_dirty_nif. When this external call is completed, its process is reassigned to a regular scheduler and can continue its work there. This capability is now fully available on the VM with SMP support; the non-SMP VM is considered obsolete and is not compiled regularly. In addition to the NIFs, the BIFs and garbage collecting also use dirty scheduling and the output of erlang: statistics / 1 was supplemented by the dirty scheduler.

However, there is now also an incompatibility with regard to NIFs: reloading modules is a strength of the platform, but is no longer possible with NIF libraries. Other incompatibilities include removing erlang: hash / 2 as well as some modules and functions in Asn1.

Positive developments

The other changes, however, as befits the high version number, are positive. The literals that are important in the language are no longer copied at great expense when sending messages, and the use of large ETS tables (Erlang Term Storage) has been accelerated. The compiler now translates Guards better into the underlying code, and the still young maps are also maturing. If a key is used multiple times in an expression, the compiler now throws a warning, which reduces careless errors. In addition, the team has optimized the pattern matching for maps.

With version 20, Unicode in Atoms is also allowed for exotic code. That too string-Modul has seen a great improvement in handling Unicode. Have further care dict, orddict and gb_trees receive. And for friends of state machines, the following applies gen_fsm now officially as deprecated; The successor is the more powerful gen_statem.

All in all, the developers did a solid job. The Erlang / OTP platform remains true to its reputation as a solid runtime environment, optimizations are careful but constant and the range of functions only increases where it is needed. It can go on up to version 30 and beyond. (rme)

Read comments (3) Go to homepage
Ad ad