Reputation: 263
I'm writing a threaded program in Rust.
Go has an environment variable GOMAXPROCS
which is used by the Go compiler to use the maximum amount of processor cores during execution. I found the RTRACEMAXPROCS
parameter here after many searches, but I can't find any documentation for this.
Is the RTRACEMAXPROCS
parameter the same as GOMAXPROCS
for Rust?
Is it good practice to use over 800K threads in single process or should I use multiple processes?
Upvotes: 4
Views: 2508
Reputation:
Rust doesn't have green threads any more. Every "task" you spawn maps to exactly one real OS thread (which is why the task terminology has fallen out of favor completely). An equivalent of GOMAXPROCS
doesn't make sense.
As for the second part of your question: 800K threads is ludicrous. It might work, but don't expect it to work nearly as well as Go's or Erlang's green threads. In particular, each thread reserves a couple of megabytes of address space and at least 4 KiB physical memory, plus whatever resources the OS needs for the thread (not a lot, I've been told). The "spawn concurrent workers for every little thing" paradigm is not very well supported.
Upvotes: 4
Reputation: 19789
From looking at the code of your source RTRACEMAXPROCS
is not actually part of Rust but of the program being used in the example.
The author is simply using that environment variable to create a thread pool of a specified size.
So short answer is No, RTRACEMAXPROCS
and GOMAXPROCS
are not the same thing.
Upvotes: 0