src: override v8 thread defaults using cli options
Based on the conversation in #4243 this implements a way to increase and decrease the size of the thread pool used in v8. Currently v8 restricts the thread pool size to `kMaxThreadPoolSize` which at this commit is (4). So it is only possible to decrease the thread pool size at the time of this commit. However with changes upstream this could change at a later date. If set to 0 then v8 would choose an appropriate size of the thread pool based on the number of online processors. PR-URL: https://github.com/nodejs/node/pull/4344 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
parent
8baaa25aec
commit
03e07d32ac
@ -99,6 +99,13 @@ Process v8 profiler output generated using the v8 option \fB\-\-prof\fR
|
||||
.BR \-\-v8\-options
|
||||
Print v8 command line options.
|
||||
|
||||
.TP
|
||||
.BR \-\-v8\-pool\-size =\fInum\fR
|
||||
Set v8's thread pool size which will be used to allocate background jobs.
|
||||
If set to 0 then v8 will choose an appropriate size of the thread pool based
|
||||
on the number of online processors. If the value provided is larger than v8's
|
||||
max then the largest value will be chosen.
|
||||
|
||||
.TP
|
||||
.BR \-\-tls\-cipher\-list =\fIlist\fR
|
||||
Specify an alternative default TLS cipher list. (Requires Node.js to be built with crypto support. (Default))
|
||||
@ -115,7 +122,6 @@ Force FIPS-compliant crypto on startup. (Cannot be disabled from script code.) (
|
||||
.BR \-\-icu\-data\-dir =\fIfile\fR
|
||||
Specify ICU data load path. (overrides \fBNODE_ICU_DATA\fR)
|
||||
|
||||
|
||||
.SH ENVIRONMENT VARIABLES
|
||||
|
||||
.TP
|
||||
|
@ -148,6 +148,8 @@ static const char** preload_modules = nullptr;
|
||||
static bool use_debug_agent = false;
|
||||
static bool debug_wait_connect = false;
|
||||
static int debug_port = 5858;
|
||||
static const int v8_default_thread_pool_size = 4;
|
||||
static int v8_thread_pool_size = v8_default_thread_pool_size;
|
||||
static bool prof_process = false;
|
||||
static bool v8_is_profiling = false;
|
||||
static bool node_is_initialized = false;
|
||||
@ -178,7 +180,6 @@ static uv_async_t dispatch_debug_messages_async;
|
||||
static node::atomic<Isolate*> node_isolate;
|
||||
static v8::Platform* default_platform;
|
||||
|
||||
|
||||
static void PrintErrorString(const char* format, ...) {
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
@ -3319,6 +3320,7 @@ static void PrintHelp() {
|
||||
" --zero-fill-buffers automatically zero-fill all newly allocated\n"
|
||||
" Buffer and SlowBuffer instances\n"
|
||||
" --v8-options print v8 command line options\n"
|
||||
" --v8-pool-size=num set v8's thread pool size\n"
|
||||
#if HAVE_OPENSSL
|
||||
" --tls-cipher-list=val use an alternative default TLS cipher list\n"
|
||||
#if NODE_FIPS_MODE
|
||||
@ -3466,6 +3468,8 @@ static void ParseArgs(int* argc,
|
||||
} else if (strcmp(arg, "--v8-options") == 0) {
|
||||
new_v8_argv[new_v8_argc] = "--help";
|
||||
new_v8_argc += 1;
|
||||
} else if (strncmp(arg, "--v8-pool-size=", 15) == 0) {
|
||||
v8_thread_pool_size = atoi(arg + 15);
|
||||
#if HAVE_OPENSSL
|
||||
} else if (strncmp(arg, "--tls-cipher-list=", 18) == 0) {
|
||||
default_cipher_list = arg + 18;
|
||||
@ -4285,8 +4289,7 @@ int Start(int argc, char** argv) {
|
||||
V8::SetEntropySource(crypto::EntropySource);
|
||||
#endif
|
||||
|
||||
const int thread_pool_size = 4;
|
||||
default_platform = v8::platform::CreateDefaultPlatform(thread_pool_size);
|
||||
default_platform = v8::platform::CreateDefaultPlatform(v8_thread_pool_size);
|
||||
V8::InitializePlatform(default_platform);
|
||||
V8::Initialize();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user