Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/libexpr/parallel-eval.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ thread_local bool Executor::amWorkerThread{false};

unsigned int Executor::getEvalCores(const EvalSettings & evalSettings)
{
/* Note: the default number of cores is currently limited to 32
due to scalability bottlenecks. */
return evalSettings.evalProfilerMode != EvalProfilerMode::disabled ? 1
: evalSettings.evalCores == 0UL ? Settings::getDefaultCores()
: evalSettings.evalCores == 0UL ? std::min(32U, Settings::getDefaultCores())
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be useful to add a small note explaining that this 32 figure is just because (as the commit message says) scalability sees diminishing returns? In case we ever fix these scalability issues, so we can again unlock much more parallelism...

: evalSettings.evalCores;
}

Expand All @@ -32,8 +34,16 @@ Executor::Executor(const EvalSettings & evalSettings)
{
debug("executor using %d threads", evalCores);
auto state(state_.lock());
// FIXME: create worker threads on demand?
for (size_t n = 0; n < evalCores; ++n)
createWorker(*state);
try {
createWorker(*state);
} catch (boost::thread_resource_error & e) {
if (n == 0)
throw Error("could not create any evaluator worker threads: %s", e.what());
warn("could only create %d evaluator worker threads: %s", n, e.what());
break;
}
Comment thread
edolstra marked this conversation as resolved.
}

Executor::~Executor()
Expand Down
Loading