Date: Mon, 3 Apr 2023 16:05:56 GMT From: Mateusz Guzik <mjg@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: 04bab189b8a5 - main - llvm/lld: damage control threading Message-ID: <202304031605.333G5uT7097880@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=04bab189b8a54974fcd9530140e4eed6ad137f48 commit 04bab189b8a54974fcd9530140e4eed6ad137f48 Author: Mateusz Guzik <mjg@FreeBSD.org> AuthorDate: 2023-04-02 12:38:49 +0000 Commit: Mateusz Guzik <mjg@FreeBSD.org> CommitDate: 2023-04-03 16:05:42 +0000 llvm/lld: damage control threading See the comment inside. Reviewed by: dim Differential Revision: https://reviews.freebsd.org/D39389 --- contrib/llvm-project/llvm/lib/Support/Threading.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/contrib/llvm-project/llvm/lib/Support/Threading.cpp b/contrib/llvm-project/llvm/lib/Support/Threading.cpp index 04a1a9e19428..3ac3695fa9ed 100644 --- a/contrib/llvm-project/llvm/lib/Support/Threading.cpp +++ b/contrib/llvm-project/llvm/lib/Support/Threading.cpp @@ -62,8 +62,19 @@ unsigned llvm::ThreadPoolStrategy::compute_thread_count() const { : sys::getHostNumPhysicalCores(); if (MaxThreadCount <= 0) MaxThreadCount = 1; - if (ThreadsRequested == 0) - return MaxThreadCount; + // Damage control threading. + // + // 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) return ThreadsRequested; return std::min((unsigned)MaxThreadCount, ThreadsRequested);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202304031605.333G5uT7097880>