thoughtarray

thoughtarray

Doing something as "at the same time" as possible

I know beam makes a scheduler per CPU (OS thread); so theoretically I can do something at exactly the same time up to the number of CPUs I have.

What is the best way to kick them all off at the same time? Is my only option to send (via Process.send or Kernel.send) a message to a process running on each scheduler? If I do that, the messages are sent out serially. Any alternative techniques or should that be considered fast enough in this ecosystem?

I posted a similar post, but I think it was too complex to bother with.

Most Liked

benwilson512

benwilson512

Author of Craft GraphQL APIs in Elixir with Absinthe

The type of question you’re asking I think requires some definitions. There is, at the end of the day, no such thing as truly “at the same time” there is “measured to be within a time bound by an observer”. How tight does the time bound need to be? Why? Who is observing this?

schneebyte

schneebyte

You could check how others are doing it.

Maybe you could tell your processes to start at a specific point in time

then just have them sleep and check time repeatedly.

/one more thing
I don’t think you can choose the specific scheduler a process is on.
:erlang.system_info(:scheduler_id)
I guess if you spawn enough processes under load it should be spread out to all available schedulers.

Last Post!

thoughtarray

thoughtarray

Thanks for the replies, all!

@benwilson512, I think the context you might be seeking is in the linked original post. That post didn’t gent any replies; so I made this post much shorter and simpler. By “at the same time”, I mean parallelism. The goal is to squish that time bound as much as possible in BEAM. I know for other languages the solution would be to start a thread per CPU core.

@al2o3cr, yeah, I think my desires are leaving the realm of practical and entering theoretical (at least in BEAM land). I do have a desire for that TCP SYN to drop in on server/listener to be parallel as possible in BEAM land. Insofar as your recommendation, it’s totally the practical way to do it and may end up what I do if I can’t find what I’m looking for.

@schneebyte, I have seen stressgrid, but not the others. Thanks for the links! I had considered a timer-based kick-off, but wasn’t sure the best way to do it in Elixir/Erlang since I was under the impression that time was pretty squishy in BEAM land.

Regarding choosing specific schedulers, I thought PartitionSupervisor would help partition its children across schedulers. Do I have that messed up in my head?

Where Next?

Popular in Questions Top

vegabook
I’m brand new to Phoenix and I have stripped one of the demo applications to the bone. I just want to get an svg up on the screen. Here i...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New

Other popular topics Top

New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1144 54921 245
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New

We're in Beta

About us Mission Statement