Oliver

Oliver

Hi.

We have a mid-sized project of roughly 75K lines of elixir code, spread over 500+ files.

When we compile this project on a 16 core machine, we can see in Grafana that only 4 cores are utilized at most. We would like to push this to at least 8 if possible.

The fascinating thing is that it caps out at 4 cores with no peaks beyond, making me wonder if there is some limit involved.

What controls how many cores are utilized and is there a cap, maximum, or default? I’ve been looking through compiler and mix documentation and have found nothing so far.

Thank you!

Showing Posts 1 to 10

ericmj

ericmj

Elixir Core Team

Elixir will use as many cores as there are scheduler threads available which defaults to the number of cores in your system.

Elixir will try to parallelize the compilation of individual files as much as possible, but any file’s compile time dependencies will have to be compiled before it which can limit the number of files that can be compiled in parallel. If you have many such dependencies in your project the compiler will not be able to use all cores.

There has been optimizations in recent Elixir releases that reduces the number of compile time dependencies so make sure you are running the latest version. @wojtekmach has also written about how to reduce the dependencies in your projects: https://dashbit.co/blog/speeding-up-re-compilation-of-elixir-projects and Rewriting imports to aliases with compilation tracers - Dashbit Blog.

Oliver

Oliver OP

Hi, @ericmj.
The machine is listed as having 16 virtual cores, being a cloud instance. Yet elixir only utilizes only 4 at any time.
I have hundreds of files, I doubt that there is no combination of 5 that can’t be compiled independently.

elixir release was 1.10.4. We can’t go forward beyond that right now for reasons having to do with the organization maintaining the infrastructure.

What system call or variables does elixir evaluate to determine how many cores to use for compilation? I could query those to learn more about why this happens.

ericmj

ericmj

Elixir Core Team

If you run iex you will get an output such as:

Erlang/OTP 23 [erts-11.0.3] [source] [64-bit] [smp:12:12] [ds:12:12:10] [async-threads:1] [hipe]

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

The number in [smp:12:12] will say how many scheduler threads are being used.

Oliver

Oliver OP

$ /opt/elixir/x86_64/1.10.4/bin/iex
Erlang/OTP 22 [erts-10.7.2.1] [source] [64-bit] [smp:16:16] [ds:16:16:10] [async-threads:1]

Seems to be recognized as having 16 cores alright.

ericmj

ericmj

Elixir Core Team

In that case the compiler will use 16 cores unless restricted by compile time dependencies reducing concurrency.

Oliver

Oliver OP

So, in principle I could add a dozen or so .ex files with no external dependencies, all in the same folder. Would I expect the core utilization to go up, or is it less deterministic than that?

If it helps the experiment, I could generate some code to make sure compilation takes a while.

axelson

axelson

Scenic Core Team

Another good test would be to try compiling a different project

Oliver

Oliver OP

Also a good idea! Any good candidates that parallelize well?

If none come to mind, I would just generate modules with a thousand functions heads each, like def add1(1), do: 2 for a long range of scalars.

ericmj

ericmj

Elixir Core Team

Yes, core utilization should go up if you have enough files and they are large enough, at least for part of the compilation.

outlog

outlog

totally understandable - but do give it a go on latest stable elixir and perhaps even master, to see/check if there are any gains there, potentially the entire solution is there.. (and yes deploying the “fix” will be a future thing then..)

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
FlyingNoodle
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews