Skip to content

Commit 0329c12

Browse files
committed
fixup! fixup! fixup! src: set UV_THREADPOOL_SIZE based on available parallelism
1 parent 56c47e8 commit 0329c12

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

src/node.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1242,7 +1242,8 @@ InitializeOncePerProcessInternal(const std::vector<std::string>& args,
12421242
char buf[64];
12431243
size_t buf_size = sizeof(buf);
12441244
int rc = uv_os_getenv("UV_THREADPOOL_SIZE", buf, &buf_size);
1245-
if (rc == UV_ENOENT) {
1245+
if (rc == UV_ENOENT &&
1246+
!per_process::dotenv_file.HasKey("UV_THREADPOOL_SIZE")) {
12461247
unsigned int parallelism = uv_available_parallelism();
12471248
unsigned int threadpool_size = std::min(std::max(4u, parallelism), 1024u);
12481249
char size_str[16];

src/node_dotenv.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,10 @@ Dotenv::ParseResult Dotenv::ParsePath(const std::string_view path) {
352352
return ParseResult::Valid;
353353
}
354354

355+
bool Dotenv::HasKey(const std::string_view key) const {
356+
return store_.contains(std::string(key));
357+
}
358+
355359
void Dotenv::AssignNodeOptionsIfAvailable(std::string* node_options) const {
356360
auto match = store_.find("NODE_OPTIONS");
357361

src/node_dotenv.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class Dotenv {
2828
void ParseContent(const std::string_view content);
2929
ParseResult ParsePath(const std::string_view path);
3030
void AssignNodeOptionsIfAvailable(std::string* node_options) const;
31+
bool HasKey(const std::string_view key) const;
3132
v8::Maybe<void> SetEnvironment(Environment* env);
3233
v8::MaybeLocal<v8::Object> ToObject(Environment* env) const;
3334

0 commit comments

Comments
 (0)