From nobody Sun Apr 09 21:35:24 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Pvll144bpz44JKV; Sun, 9 Apr 2023 21:35:25 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Pvll11sk7z4MVm; Sun, 9 Apr 2023 21:35:25 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1681076125; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ipW4lbkCfgatFp2mP8EMiAMG4UqAJEmPz1EHZr6Paa8=; b=Njgs4pSp4+E/QmHHdhI9HNiup1nSOYPAaKfWKYY5poiaK/ICDfGJPTS5d8mD50nrKXJe8z dPtdFeR14XNYwUYlGcw1MzGLDbqkg+CqikCiw4YjKbsYqYBN97Ns1P4P7QuIQLs171P6ZR L6rc+3tiuY9JNaOKfDyhLUCT7icnCi2Mmvdf//haxOb1JPox2HwvH+l0wYQOBJ01kaLl9x w0VcyLsHYEwl13FYlUAjWk++sL7Ngg0P96XwD0AQP4LdVfI3xe9LN1DdurNjCVFGrgpsAR R/oNEt5DnHcKIYM8xmF/icO5DalAhtwdHvHnTJBk1AnR4tCEe8McNbwLlVdnWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1681076125; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ipW4lbkCfgatFp2mP8EMiAMG4UqAJEmPz1EHZr6Paa8=; b=QDf8TO7zBZY3GNozxtQ8wadePKJwbPnxI0d/n7+ZUPHA9teuwvxMhWZD8Ny1muyfqAuu02 Y2AtcBWbUWoumnYjf+0wjPBWux3h8xH7Uw0NE68Nhi4c+LRzyGMtw7YLGVv+aTsVvOAxn0 k4tVXgVHPV8f15TEolp3IraiTbOpTTZ88uhOMIlEK03NxMxhckWUA0tL77kfDZsLCIKJMn ICLWIdfJVqY3QJh6/KqvNCS+OYvWOmTHp1VvRAQeafL/mF4Dig2WMD5oX2zR/5UBB9fHKx pfnXZFAJwbkxbxZ5UfVo3M3jLZtZVIdcJu2qPZVqdfIu5+mUqGlEPMNHY58MDw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1681076125; a=rsa-sha256; cv=none; b=oq2UvkwO/LBmpwsGrNo8DhJh+01LitNH1ZDntrVwEI67t8bOPtuhi1eBR5tSzvWYkB+iyz oOlOx9UUiJxym8WouJXwONeY2PLPq8/l2Ef3yUHX6OAjrLTRoOrjzptelN4g4uWbSQFCYL NTCmJBKvX3nrhvx4l08W3VtbWASxVIYLBuKi6ohbOd3nR0YWZKfSRZhgd367KGT3/aniZP s4bdygDgEqkzb4XlKkw3V2cY7XwB83M3hJOSSnYjroBnvvFclXRTGAsUs2VtsT8CGYsF6C KypcdoiGLtAqBdKEL3kPLTTM39eNGRh3MyFfMCpqQuEqHst70e4hIF6sBiPXJA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Pvll05KbtzPKV; Sun, 9 Apr 2023 21:35:24 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 339LZOU8081686; Sun, 9 Apr 2023 21:35:24 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 339LZOYF081685; Sun, 9 Apr 2023 21:35:24 GMT (envelope-from git) Date: Sun, 9 Apr 2023 21:35:24 GMT Message-Id: <202304092135.339LZOYF081685@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dimitry Andric Subject: git: 801fd0db28cb - stable/13 - llvm/lld: damage control threading List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dim X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 801fd0db28cb43bee27dd297b7be92a39d9dff98 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=801fd0db28cb43bee27dd297b7be92a39d9dff98 commit 801fd0db28cb43bee27dd297b7be92a39d9dff98 Author: Mateusz Guzik AuthorDate: 2023-04-02 12:38:49 +0000 Commit: Dimitry Andric CommitDate: 2023-04-09 14:54:53 +0000 llvm/lld: damage control threading See the comment inside. Reviewed by: dim Differential Revision: https://reviews.freebsd.org/D39389 (cherry picked from commit 04bab189b8a54974fcd9530140e4eed6ad137f48) --- 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);