Erlang BEAM abbreviations

Erlang is a well-known programming language that is known for (among other things) lightweight threading. Erlang is usually implemented with a BEAM machine . Description (H'97) of the Erlang BEAM machine says

To ensure fair scheduling, the process is suspended after a fixed number of cuts , and then the first process in the queue is resumed.

I am interested in this concept of reduction. According to (H'97), only the following BEAMs are considered subtractions:

  • C / CO / ResC : Calls a local / resident Erlang function
  • CL : undo the current stack stack. Calling a local function Erlang.
  • CEx / TrCEx . Call external Erlang function (traceable or otherwise).
  • CExL / TrCExL . Cancel the current stack stack and call the external Erlang fuction (traceable or otherwise).
  • M_C_r : Load the x (0) argument register. Call the Erlang resident function.
  • M_CL_r : Load the x (0) argument register. Discard the current stack stack. Calling a local function Erlang.

They all involve calling a function. In contrast, calls to C functions (such as TrC / TrCO ) and calls to inline functions (such as those called by Bif_0 _ ) are not counted as shorthand.

Questions. ... After this preamble, here's what I would like to know.

  • Why are abbreviations used for scheduling between threads and not time slices?
  • Why only the above commands speed up the cutback counter?
  • The description in (H'97) is a little out of date, how does Erlang's modern graphics handle?

(H'97) B. Hausman, BEAM Erlang Virtual Machine Specification .

+3


source to share


2 answers


I will try to answer your questions.

1) The main reason for not using time slots is performance and portability. It is expensive to read the monotonic time value from the operating system, and if we need to do this for every function call, the overhead becomes quite large. The cost also varies greatly from OS to OS. The contraction tracking mechanism, however, only requires that the machine be good at decreasing integers that most machines do.



2) They don't. This list is, as you say, very outdated. Since then, much of the VM's work has been rewritten. As a general rule; a function call (not a return) or anything that can take an unknown amount of time reduces the number of shortcuts. This includes bifs, nifs, gc, sending / receiving messages and maybe more that I can't think of right now.

3) Planning and anticipation are two different things. You might want to see my webinar I did a couple of years ago on how scheduling is done: https://www.youtube.com/watch?v=tBAM_N9qPno

+2


source


I only know the answer to the first question:



  • Time slices are not necessarily accurate on all platforms and operating systems; using acronyms ensures consistent behavior across all environments.
+4


source







All Articles