From ea5f1f98e0043d6f8deb9edeb0525a19adcf3429 Mon Sep 17 00:00:00 2001 From: Alex Mo Date: Mon, 19 Jan 2015 17:58:29 -0600 Subject: [PATCH] doc: explain how the threadpool is allocated Add an explanation about how libuv implements the threadpool and why. This is so users know what behavior they should expect when they make use of threads. Related issue: https://github.com/libuv/libuv/issues/145 PR-URL: https://github.com/libuv/libuv/pull/146 Reviewed-By: Ben Noordhuis --- docs/src/threadpool.rst | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/src/threadpool.rst b/docs/src/threadpool.rst index 66ff53e2..89f00844 100644 --- a/docs/src/threadpool.rst +++ b/docs/src/threadpool.rst @@ -12,7 +12,11 @@ Its default size is 4, but it can be changed at startup time by setting the ``UV_THREADPOOL_SIZE`` environment variable to any value (the absolute maximum is 128). -The threadpool is global and shared across all event loops. +The threadpool is global and shared across all event loops. When a particular +function makes use of the threadpool (i.e. when using :c:func:`uv_queue_work`) +libuv preallocates and initializes the maximum number of threads allowed by +``UV_THREADPOOL_SIZE``. This causes a relatively minor memory overhead +(~1MB for 128 threads) but increases the performance of threading at runtime. Data types