Skip to content

Commit 2dd7b5d

Browse files
authored
Merge pull request #390 from mrmlnc/update_concurrency_docs
ISSUE-381: How much parallelism does this package uses?
2 parents df68db1 + 499018b commit 2dd7b5d

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,22 @@ Specifies the maximum number of concurrent requests from a reader to read direct
293293

294294
> :book: The higher the number, the higher the performance and load on the file system. If you want to read in quiet mode, set the value to a comfortable number or `1`.
295295
296+
<details>
297+
298+
<summary>More details</summary>
299+
300+
In Node, there are [two types of threads][nodejs_thread_pool]: Event Loop (code) and a Thread Pool (fs, dns, …). The thread pool size controlled by the `UV_THREADPOOL_SIZE` environment variable. Its default size is 4 ([documentation][libuv_thread_pool]). The pool is one for all tasks within a single Node process.
301+
302+
Any code can make 4 real concurrent accesses to the file system. The rest of the FS requests will wait in the queue.
303+
304+
> :book: Each new instance of FG in the same Node process will use the same Thread pool.
305+
306+
But this package also has the `concurrency` option. This option allows you to control the number of concurrent accesses to the FS at the package level. By default, this package has a value equal to the number of cores available for the current Node process. This allows you to set a value smaller than the pool size (`concurrency: 1`) or, conversely, to prepare tasks for the pool queue more quickly (`concurrency: Number.POSITIVE_INFINITY`).
307+
308+
So, in fact, this package can **only make 4 concurrent requests to the FS**. You can increase this value by using an environment variable (`UV_THREADPOOL_SIZE`), but in practice this does not give a multiple advantage.
309+
310+
</details>
311+
296312
#### cwd
297313

298314
* Type: `string`
@@ -793,3 +809,5 @@ This software is released under the terms of the MIT license.
793809
[vultr_pricing_baremetal]: https://www.vultr.com/pricing/baremetal
794810
[wikipedia_case_sensitivity]: https://en.wikipedia.org/wiki/Case_sensitivity
795811
[zotac_bi323]: https://www.zotac.com/ee/product/mini_pcs/zbox-bi323
812+
[nodejs_thread_pool]: https://nodejs.org/en/docs/guides/dont-block-the-event-loop
813+
[libuv_thread_pool]: http://docs.libuv.org/en/v1.x/threadpool.html

0 commit comments

Comments
 (0)