One core or all of them
- The problem
- Code written for one core usually has to be rewritten, or at least re-checked, to use several.
- An example
- A web service starts on one core. When the load grows, it should use all of them without a rewrite.
- What Nikaia checks
- The choice is one line in
nikaia.toml:user-parallelism = "no"(the default) or"yes". Atno, two pieces of your code are never running at the same moment. Atyes, a multi-threaded runtime spreads the work over the cores, and thread safety is checked at compile time. A library built atnois still checked against the rules parallel code needs, so it also works when a program built atyesuses it. - The limit
- The setting allows parallelism; it does not set a thread count. How many threads serve
yesis the runtime’s choice, because it depends on the machine. Atno, only your own code is limited to one thread: waiting for I/O happens on the runtime’s own threads, and the standard library may still use every core.
The setting
[build]
user-parallelism = "no" # the default; "yes" for the multi-threaded runtime
Go deeper
More under Very fast: 1BRC study: the Nikaia compiler vs. human vs. AINo garbage collector, no freeChecks that are proved are dropped