Skip to content

Commit ed08457

Browse files
authored
Document how to set the threadpool sizes with JULIA_NUM_THREADS (#55425)
Fixes #48960, fixes #50936.
1 parent fdc1090 commit ed08457

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

doc/src/manual/environment-variables.md

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -328,16 +328,25 @@ a master process to establish a connection before dying.
328328

329329
### [`JULIA_NUM_THREADS`](@id JULIA_NUM_THREADS)
330330

331-
An unsigned 64-bit integer (`uint64_t`) that sets the maximum number of threads
332-
available to Julia. If `$JULIA_NUM_THREADS` is not positive or is not set, or
333-
if the number of CPU threads cannot be determined through system calls, then the
334-
number of threads is set to `1`.
331+
An unsigned 64-bit integer (`uint64_t`) or string that sets the maximum number
332+
of threads available to Julia. If `$JULIA_NUM_THREADS` is not set or is a
333+
non-positive integer, or if the number of CPU threads cannot be determined
334+
through system calls, then the number of threads is set to `1`.
335335

336336
If `$JULIA_NUM_THREADS` is set to `auto`, then the number of threads will be set
337-
to the number of CPU threads.
337+
to the number of CPU threads. It can also be set to a comma-separated string to
338+
specify the size of the `:default` and `:interactive` [threadpools](@ref
339+
man-threadpools), respectively:
340+
```bash
341+
# 5 threads in the :default pool and 2 in the :interactive pool
342+
export JULIA_NUM_THREADS=5,2
343+
344+
# `auto` threads in the :default pool and 1 in the :interactive pool
345+
export JULIA_NUM_THREADS=auto,1
346+
```
338347

339348
!!! note
340-
`JULIA_NUM_THREADS` must be defined before starting julia; defining it in
349+
`JULIA_NUM_THREADS` must be defined before starting Julia; defining it in
341350
`startup.jl` is too late in the startup process.
342351

343352
!!! compat "Julia 1.5"
@@ -347,6 +356,9 @@ to the number of CPU threads.
347356
!!! compat "Julia 1.7"
348357
The `auto` value for `$JULIA_NUM_THREADS` requires Julia 1.7 or above.
349358

359+
!!! compat "Julia 1.9"
360+
The `x,y` format for threadpools requires Julia 1.9 or above.
361+
350362
### [`JULIA_THREAD_SLEEP_THRESHOLD`](@id JULIA_THREAD_SLEEP_THRESHOLD)
351363

352364
If set to a string that starts with the case-insensitive substring `"infinite"`,

0 commit comments

Comments
 (0)