Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp801346pxy; Fri, 30 Apr 2021 17:21:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy47vORxKLhBjAQiKRzraXlm450bEQrv8qgQwGOkztXiL5lhHkuYEvI7lyiw0f0QCI5l1W5 X-Received: by 2002:a17:906:a0c6:: with SMTP id bh6mr6916700ejb.359.1619828495549; Fri, 30 Apr 2021 17:21:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619828495; cv=none; d=google.com; s=arc-20160816; b=wNKRo5y0zRUt79/iyM2B+rBMFzwXZePU48LlCcmF9S/rM99NQCGrfmdR2bo4E9qD6N vHjaIOXkN03MXwPPbBn+RrdqrdjBbmDGmtIJ0SpsGo+8dtqZjoeHzQG7kkwUw7Pt86qW nZ0FF732HCwG1y79EqRXexx90/dfkWovzen3YUAW/TyGlEJVllf7W04Epq2GzP51DRYa s+Leoud4yRa/IWoyCRKoc7uarL9wcjlm/lbGcaxOzkO3VVpdKeqhNmzek239DuLroEiw FkFdC3LOqQR8Ug9OdKTmPUbaoMrEsGTrRCvxh11SIcJAEDT0jRCiuCL2Yv6X7jN94zgr ZHxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=zabmtldstojRTyrvpu95m7nCjwuyjWVTvStP8C2VfyM=; b=cahI2M6wnAlEZhyucMyBsdXY9bptVGtJu3t5/VM85jOiTuhzXuVzYygL3g9EJ44tA+ LOWqiu/ZHIlGyex3mgsCd0UMO8iLl3U0WBYSuWqib7hldSnU8hZhJGb6TdUgWwQMrFQ6 Vy/FVblvlHiU60KEhy97yjUrD6OVE5woCA4YuCw2KMz8/n8yeoRppWsuLfcsDYUCgDwO jSOqRL4rLvqbFyluYx1ahl7RTRYBv4RRscBMbUHbUuMliTYc+IbDSWQwrMEI2WlQ0zRi hOJDHZZhIaIdB3m3grIEiplFKZ2Opp+2kZpbf8JKEN17E45D0hltW0ls5f/eGhNzI/6b aZAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=jr0S0e1w; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o5si3577812edv.77.2021.04.30.17.21.10; Fri, 30 Apr 2021 17:21:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=jr0S0e1w; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230363AbhEAAVB (ORCPT + 99 others); Fri, 30 Apr 2021 20:21:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229915AbhEAAVA (ORCPT ); Fri, 30 Apr 2021 20:21:00 -0400 Received: from mail-lf1-x136.google.com (mail-lf1-x136.google.com [IPv6:2a00:1450:4864:20::136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE672C06174A for ; Fri, 30 Apr 2021 17:20:10 -0700 (PDT) Received: by mail-lf1-x136.google.com with SMTP id b23so30129110lfv.8 for ; Fri, 30 Apr 2021 17:20:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=zabmtldstojRTyrvpu95m7nCjwuyjWVTvStP8C2VfyM=; b=jr0S0e1w7axDLPwaJw2Ket382b0kL6+bXfTPFA0r4MLHSMWtvt79KtHMJ2Xlnr4xKF cqSbfTFc/CG7Wi9G6RaWJKXOIv72kCf6DVXrInYso6unss7x/E2DSbKopoAYpfJ1iFvs 4RMivEQ1aNGb51KOTY247R9OwhZavfXCCXDcE2UEs02zu4SgHih6sPatb4WBusTEWGS5 R3yhcgzwCfPeAa9NmpC9ZBz1w040d8v2T0uIXH+45vXC6Jad51N+GMcCrRdclpGJO+qQ nXU3PPWhhO2dcHizkC6NM8eam5+si2Y0lMqbHU29i3CM/iTu5X3r2eQVrINqjMKf3u0R Z8cQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=zabmtldstojRTyrvpu95m7nCjwuyjWVTvStP8C2VfyM=; b=aFYyOBQyFtOExQeloCVWoIk1i86URwVUKqBwJL+9bP1cQdQyPHCcuSDkaSMYZuzYfi RGUeBEpJLjpNB1ZugtjHnwSSFjivqWTroHGEyKmKVGSNiLcMBas4wjdnGQlKo4LQfu9P WoLvFxzfV8I9HDYCh2XXzfkKyZwe7+LbxLAz6dVgnSmHVNAVdGgI0cOHdzQdlji8+voZ UtunPGsMXsPexRJPScjUHJi2fnJ8q72jx91aBmko1L0nOuhbBU0q+O+PMKomRAA2YT0f vR369NomjEmtkSFTBc8ZzlhRCSootCQlo2oJW8+q9R1Zh/9LWqJxONsvjOeIlyo8BJwE BPeA== X-Gm-Message-State: AOAM530sUAhISwdYRcNvAB/F+9/AS7hUwTaHdPfGbbYAJyTeboN3qsQn CX96Tb5kSD6DOnCiY1lwpIrDVhy66P3+Cvcngj+TFA== X-Received: by 2002:a05:6512:94d:: with SMTP id u13mr4783892lft.368.1619828409137; Fri, 30 Apr 2021 17:20:09 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Nick Desaulniers Date: Fri, 30 Apr 2021 17:19:57 -0700 Message-ID: Subject: Re: Very slow clang kernel config .. To: Linus Torvalds , Masahiro Yamada Cc: Nathan Chancellor , Linux Kernel Mailing List , clang-built-linux Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 29, 2021 at 7:22 PM Nick Desaulniers wrote: > > On Thu, Apr 29, 2021 at 5:19 PM Nick Desaulniers > wrote: > > > > On Thu, Apr 29, 2021 at 2:53 PM Linus Torvalds > > wrote: > > > > > > I haven't looked into why this is so slow with clang, but it really is > > > painfully slow: > > > > > > time make CC=clang allmodconfig > > > real 0m2.667s > > > > > > vs the gcc case: > > > > > > time make CC=gcc allmodconfig > > > real 0m0.903s > > > > Can > > you provide info about your clang build such as the version string, > > and whether this was built locally perhaps? > > d'oh it was below. > > > > This is on my F34 machine: > > > > > > clang version 12.0.0 (Fedora 12.0.0-0.3.rc1.fc34) A quick: $ perf record -e cycles:pp --call-graph lbr make LLVM=1 LLVM_IAS=1 -j72 allmodconfig $ perf report --no-children --sort=dso,symbol shows: 2.35% [unknown] [k] 0xffffffffabc00fc7 + 2.29% libc-2.31.so [.] _int_malloc 1.24% libc-2.31.so [.] _int_free + 1.23% ld-2.31.so [.] do_lookup_x + 1.14% libc-2.31.so [.] __strlen_avx2 + 1.06% libc-2.31.so [.] malloc + 1.03% clang-13 [.] llvm::StringMapImpl::LookupBucketFor 1.01% libc-2.31.so [.] __memmove_avx_unaligned_erms + 0.76% conf [.] yylex + 0.68% clang-13 [.] llvm::Instruction::getNumSuccessors + 0.63% libbfd-2.35.2-system.so [.] bfd_hash_lookup + 0.63% clang-13 [.] llvm::PMDataManager::findAnalysisPass + 0.63% ld-2.31.so [.] _dl_lookup_symbol_x 0.62% libc-2.31.so [.] __memcmp_avx2_movbe 0.60% libc-2.31.so [.] __strcmp_avx2 + 0.56% clang-13 [.] llvm::ValueHandleBase::AddToUseList + 0.56% clang-13 [.] llvm::operator==, llvm::detail::Dense 0.53% clang-13 [.] llvm::SmallPtrSetImplBase::insert_imp_big (yes, I know about kptr_restrict)(sorry if there's a better way to share such perf data; don't you need to share perf.data and the same binary, IIRC?) The string map lookups look expected; the compiler flags are one very large string map; though we've identified previously perhaps hashing could be sped up. llvm::Instruction::getNumSuccessors looks unexpectedly like codegen, but this was a trace of `allmodconfig`; I wouldn't be surprised if this is LLVM=1 setting HOSTCC=clang; might be good to try to isolate those out. Some other questions that came to mind thinking about this overnight: - is Kbuild/make doing more work than is necessary when building with clang (beyond perhaps a few more cc-option checks)? I don't think perf is the right tool for profiling GNU make. V=1 to make hides a lot of the work macros like cc-option are doing. - is clang doing more work than necessary for just checking support of command line flags? Probably. I'm not sure that has been optimized before, but if we pursue that but the slowdown was more so the previous point, that would potentially be a waste of time. -- Thanks, ~Nick Desaulniers