From nobody Mon Apr 03 16:05:56 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 4Pqwjc3nySz42wjC; Mon, 3 Apr 2023 16:05:56 +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 4Pqwjc3C50z4Dsn; Mon, 3 Apr 2023 16:05:56 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1680537956; 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=I4r1b15LvXRHu3DbLLa6CRTcx+wfqLDEB/l1avfiK0s=; b=TlADbCjQMNCBQpZOXpOHxsf7aehpUxE2xpusa6mTFNJq706FpoeUMTFwBqvDnY7HTuVwQX lEtET9c34SHA39ywChBTy8Sqp6cZjrBbkwbZq76y2MtRQ8r015EgS4iOwzH4093t2dsx9U xRmTR8/ZQZfMSlOCLynnVOHAyKwZ27feCPCEYkM0YfXt/4eddMQ69uklc13qxtI12cqZR1 F4Zciq7GDpPtirv8x55+JEil852q329Tm/d4iZXYXKkCNFI+6TvpRR2mV7V0IKxYhOmauW 5SgrxdDVi3FrL1cKEpV++rRO2EACHJQSJAt02pn6ab+ByDqoBtd1YJzQq895Yw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1680537956; 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=I4r1b15LvXRHu3DbLLa6CRTcx+wfqLDEB/l1avfiK0s=; b=Z23Mn2qGkv6C5j2CwbLFZakK+5nVSqJR9ZnfSIFi8yoeCxW4DPakoEgashkO2+bqI2JchS IkZppK6eduxj+FyWOrQ9H038h+7xP0bD71DmAMJInBEQhbyiaFMp2OkMKSA0JLGHID2z8w 6CTRqjdaHkLxJiVDdk4xhAg59K58y+W6JSatTTbkPsq44ZxfWj+G5eOjlwIlO6F+14thdS i3Rc3QairMGBCiyaGUw9GeUgN1x4l9kmedMAyYhyvKkteJ5ksLjz8DJpvZp1ILbi0CwV4O Dp6HZCoG9GK9lgjwxOW3fAFTurRa/uf4zxGzvZGgvGyaL/UENAvMS1BKk9tFZQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1680537956; a=rsa-sha256; cv=none; b=wYDzK/HcjHYDqma1jVhnPyXo1qGvLbok66WbBHJwIUJnTGrFoJOLzlEoVx9BwuLoE0zDF4 +gAyWR4nFqWX+qjrk/hkhgJwxunQc6CahH4F+4n83XMF5ZlXC0nX/Km2d+mrW4N+HgQzfg +Qc/1ZdltyJoS7Vq6b3ZUcRpbNbIHEbSxTSvrTroyIG0lUOt6qTy46ulBReVCUX6eGfOL+ ER6+ctTLxAb9N3bPrTBtwM5yjDT1XUzZVvnEkwM43rSc5lT2ddKkzcib6jKOhI09EA1JDZ QF4s2u4qGB3elU3t35cwf7J6zINtT9pd+CVKyssgWGsVSWOSOUeQInaRzrbcbQ== 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 4Pqwjc2GyHz14QW; Mon, 3 Apr 2023 16:05:56 +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 333G5ua4097881; Mon, 3 Apr 2023 16:05:56 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 333G5uT7097880; Mon, 3 Apr 2023 16:05:56 GMT (envelope-from git) Date: Mon, 3 Apr 2023 16:05:56 GMT Message-Id: <202304031605.333G5uT7097880@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: 04bab189b8a5 - main - 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: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 04bab189b8a54974fcd9530140e4eed6ad137f48 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=04bab189b8a54974fcd9530140e4eed6ad137f48 commit 04bab189b8a54974fcd9530140e4eed6ad137f48 Author: Mateusz Guzik AuthorDate: 2023-04-02 12:38:49 +0000 Commit: Mateusz Guzik 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);