Can CRYSTAL_WORKERS=X be set in source code?

That may apply to the kind of software you write, but it hardly works as a general rule.

I certainly wouldn’t want some random simple CLI tool spin up ridiculously many threads by default just because it happens to run on a machine with 50 cores.

We should give developers more flexibility for defining the multithreading characteristics of a program. As a simple first step I would consider a compile-time variable to specify the default value (can still be overriden at runtime, but it would provide a default that adapts to the kind of program). A special value representing the number of available cores might also be a good idea to improve that story (specifically for high-computing use cases mentioned by @jzakiya).

3 Likes