rogach

rogach

Why recon reports 2 schedulers even though BEAM was supposedly started with 1?

I’ve explicitly set number of schedulers to 1 on IEX startup:

iex --erl "+S 1" -S mix
Erlang/OTP 26 [erts-14.2.5] [source] [64-bit] [smp:1:1] [ds:1:1:10] [async-threads:1] [jit:ns]

Interactive Elixir (1.16.2) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)>

However, when I try checking scheduler usage via recon library, it reports two schedulers:

iex(1)> :recon.scheduler_usage(1000)
[{1, 7.620530725717925e-4}, {2, 0.0}]

Why is that? Where does this second scheduler come from?

Marked As Solved

03juan

03juan

It’s reporting on the number of total schedulers that were active during the 1000ms timespan, including dirty_cpu_schedulers.

:recon.scheduler_usage/1 executes :erlang.statistics(:scheduler_wall_time), whose docs explain:

Only information about schedulers that are expected to handle CPU bound work is included in the return values from this function. […]

Normal schedulers will have scheduler identifiers in the range 1 =< SchedulerId =< erlang:system_info(schedulers). Dirty CPU schedulers will have scheduler identifiers in the range erlang:system_info(schedulers) < SchedulerId =< erlang:system_info(schedulers) + erlang:system_info(dirty_cpu_schedulers).

The +S 1 flag is setting the number of “normal” scheduler threads used by the emulator.

Scheduler threads online schedules Erlang processes and Erlang ports, and execute Erlang code and Erlang linked-in driver code

There will always be at least 1 each of

  • dirty cpu schedulers

    execute CPU-bound native functions, such as NIFs, linked-in driver code, and BIFs that cannot be managed cleanly by the normal emulator schedulers

  • dirty io schedulers

    execute I/O-bound native functions, such as NIFs and linked-in driver code, which cannot be managed cleanly by the normal emulator schedulers

Here’s how my 16-core system boots with the same scheduler flag.

$ iex --erl "+S 1"
Erlang/OTP 26 [erts-14.2.5] [source] [64-bit] [smp:1:1] [ds:1:1:10] [async-threads:1] [jit:ns]

Interactive Elixir (1.16.2) - press Ctrl+C to exit (type h() ENTER for help)

iex(1)> :erlang.system_info(:schedulers)
1
iex(2)> :erlang.system_info(:dirty_cpu_schedulers)
1
iex(3)> :erlang.system_info(:dirty_io_schedulers)
10
iex(4)> :erlang.statistics(:microstate_accounting) |> Enum.map(& {&1.type, &1.id}) |> Enum.sort()
[
  async: 0,
  aux: 1,
  dirty_cpu_scheduler: 1,
  dirty_io_scheduler: 1,
  dirty_io_scheduler: 2,
  dirty_io_scheduler: 3,
  dirty_io_scheduler: 4,
  dirty_io_scheduler: 5,
  dirty_io_scheduler: 6,
  dirty_io_scheduler: 7,
  dirty_io_scheduler: 8,
  dirty_io_scheduler: 9,
  dirty_io_scheduler: 10,
  poll: 0,
  scheduler: 1
]

By the way, that’s the info the BEAM prints out at the start [smp:1:1] [ds:1:1:10], equivalent to the flags iex --erl "+S 1:1 +SDcpu 1:1 +SDio 10"

Where Next?

Popular in Questions Top

joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 record...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
mathew4509
I have a list say x = ["23gh", "56kh", "97mh"] I would like to pass each element to Val in each iteration. Say, in iteration 1 -------...
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
chrisalley
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
Exadra37
Sometimes I want to check if the input into a function is not a blank string. My first approach: defmodule Example do def do_stuff(s...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New

Other popular topics Top

rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list....
New
peerreynders
Manning 2016 Halloween weekend sale via Deal of the Day Friday, October 28 - Half off all MEAPs - code WM102816LT Saturday, October 29 ...
326 29600 154
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 35421 110
New
Jim
As a follow up to my earlier question: I have the code compiling and running but not getting a successful login from the rest server. ...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? https://hexdocs.pm/ecto/Ecto.Repo.h...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers' Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
AstonJ
We’ve put together this wiki for Phoenix LiveView - please feel free to add any info you feel is worth including. What is Phoenix LiveV...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New

We're in Beta

About us Mission Statement