llvm/lld: damage control threading
See the comment inside. Reviewed by: dim Differential Revision: https://reviews.freebsd.org/D39389
This commit is contained in:
parent
2a58b312b6
commit
04bab189b8
@ -62,8 +62,19 @@ unsigned llvm::ThreadPoolStrategy::compute_thread_count() const {
|
|||||||
: sys::getHostNumPhysicalCores();
|
: sys::getHostNumPhysicalCores();
|
||||||
if (MaxThreadCount <= 0)
|
if (MaxThreadCount <= 0)
|
||||||
MaxThreadCount = 1;
|
MaxThreadCount = 1;
|
||||||
if (ThreadsRequested == 0)
|
// Damage control threading.
|
||||||
return MaxThreadCount;
|
//
|
||||||
|
// There are no heuristics to figure out how many threads makes sense to spawn,
|
||||||
|
// all while rolling with all available hw threads starts being detrimental to
|
||||||
|
// performance really early.
|
||||||
|
//
|
||||||
|
// Work around by putting a hard cap unless the user explicitly requested a certain amount.
|
||||||
|
//
|
||||||
|
// See https://discourse.llvm.org/t/avoidable-overhead-from-threading-by-default/69160
|
||||||
|
// for more details.
|
||||||
|
if (ThreadsRequested == 0) {
|
||||||
|
return std::min(MaxThreadCount, 4);
|
||||||
|
}
|
||||||
if (!Limit)
|
if (!Limit)
|
||||||
return ThreadsRequested;
|
return ThreadsRequested;
|
||||||
return std::min((unsigned)MaxThreadCount, ThreadsRequested);
|
return std::min((unsigned)MaxThreadCount, ThreadsRequested);
|
||||||
|
Loading…
Reference in New Issue
Block a user