Skip to content

Commit 838c762

Browse files
committed
fixup! fixup! fixup! src: set UV_THREADPOOL_SIZE based on available parallelism
1 parent 064fdf8 commit 838c762

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
@@ -1229,7 +1229,8 @@ InitializeOncePerProcessInternal(const std::vector<std::string>& args,
12291229
char buf[64];
12301230
size_t buf_size = sizeof(buf);
12311231
int rc = uv_os_getenv("UV_THREADPOOL_SIZE", buf, &buf_size);
1232-
if (rc == UV_ENOENT) {
1232+
if (rc == UV_ENOENT &&
1233+
!per_process::dotenv_file.HasKey("UV_THREADPOOL_SIZE")) {
12331234
unsigned int parallelism = uv_available_parallelism();
12341235
unsigned int threadpool_size = std::min(std::max(4u, parallelism), 1024u);
12351236
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)