You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -362,12 +362,16 @@ This class extends [`EventEmitter`][] from Node.js.
362
362
only makes sense to specify if there is some kind of asynchronous component
363
363
to the task. Keep in mind that Worker threads are generally not built for
364
364
handling I/O in parallel.
365
-
* `useAtomics`: (`boolean`) Use the [`Atomics`][] API for faster communication
365
+
* `atomics`: (`sync` | `async` | `disabled`) Use the [`Atomics`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics) API for faster communication
366
366
between threads. This is on by default. You can disable `Atomics` globally by
367
-
setting the environment variable `PISCINA_DISABLE_ATOMICS` to `1`.
368
-
If `useAtomics` is `true`, it will cause to pause threads (stoping all execution)
369
-
between tasks. Ideally, threads should wait for all operations to finish before
370
-
returning control to the main thread (avoid having open handles within a thread).
367
+
setting the environment variable `PISCINA_DISABLE_ATOMICS` to `1` .
368
+
If `atomics` is `sync`, it will cause to pause threads (stoping all execution)
369
+
between tasks. Ideally, threads should wait for all operations to finish before
370
+
returning control to the main thread (avoid having open handles within a thread). If still want to have the possibility
371
+
of having open handles or handle asynchrnous tasks, you can set the environment variable `PISCINA_ENABLE_ASYNC_ATOMICS` to `1` or setting `options.atomics` to `async`.
372
+
373
+
> **Note**: The `async` mode comes with performance penalties and can lead to undesired behaviour if open handles are not tracked correctly.
374
+
371
375
* `resourceLimits`: (`object`) See [Node.js new Worker options][]
372
376
* `maxOldGenerationSizeMb`: (`number`) The maximum size of each worker threads
Copy file name to clipboardExpand all lines: docs/docs/api-reference/class.md
+15-4Lines changed: 15 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -47,12 +47,20 @@ This class extends [`EventEmitter`](https://nodejs.org/api/events.html) from Nod
47
47
only makes sense to specify if there is some kind of asynchronous component
48
48
to the task. Keep in mind that Worker threads are generally not built for
49
49
handling I/O in parallel.
50
-
-`useAtomics`: (`boolean`) Use the [`Atomics`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics) API for faster communication
50
+
-`atomics`: (`sync` | `async` | `disabled`) Use the [`Atomics`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics) API for faster communication
51
51
between threads. This is on by default. You can disable `Atomics` globally by
52
-
setting the environment variable `PISCINA_DISABLE_ATOMICS` to `1`.
53
-
If `useAtomics` is `true`, it will cause to pause threads (stoping all execution)
52
+
setting the environment variable `PISCINA_DISABLE_ATOMICS` to `1`.
53
+
If `atomics` is `sync`, it will cause to pause threads (stoping all execution)
54
54
between tasks. Ideally, threads should wait for all operations to finish before
55
-
returning control to the main thread (avoid having open handles within a thread).
55
+
returning control to the main thread (avoid having open handles within a thread). If still want to have the possibility
56
+
of having open handles or handle asynchrnous tasks, you can set the environment variable `PISCINA_ENABLE_ASYNC_ATOMICS` to `1` or setting `options.atomics` to `async`.
57
+
58
+
** :::info
59
+
**Note**: The `async` mode comes with performance penalties and can lead to undesired behaviour if open handles are not tracked correctly.
60
+
Workers should be designed to wait for all operations to finish before returning control to the main thread, if any background operations are still running
61
+
`async` can be of help (e.g. for cache warming, etc).
62
+
:::
63
+
**
56
64
-`resourceLimits`: (`object`) See [Node.js new Worker options](https://nodejs.org/api/worker_threads.html#worker_threads_new_worker_filename_options)
57
65
-`maxOldGenerationSizeMb`: (`number`) The maximum size of each worker threads
58
66
main heap in MB.
@@ -93,6 +101,9 @@ This class extends [`EventEmitter`](https://nodejs.org/api/events.html) from Nod
93
101
-`workerHistogram`: (`boolean`) By default `false`. It will hint the Worker pool to record statistics for each individual Worker
94
102
-`loadBalancer`: ([`PiscinaLoadBalancer`](#piscinaloadbalancer)) By default, Piscina uses a least-busy algorithm. The `loadBalancer`
95
103
option can be used to provide an alternative implementation. See [Custom Load Balancers](../advanced-topics/loadbalancer.mdx) for additional detail.
104
+
-`workerHistogram`: (`boolean`) By default `false`. It will hint the Worker pool to record statistics for each individual Worker
105
+
-`loadBalancer`: ([`PiscinaLoadBalancer`](#piscinaloadbalancer)) By default, Piscina uses a least-busy algorithm. The `loadBalancer`
106
+
option can be used to provide an alternative implementation. See [Custom Load Balancers](../advanced-topics/loadbalancer.mdx) for additional detail.
96
107
97
108
:::caution
98
109
Use caution when setting resource limits. Setting limits that are too low may
0 commit comments