Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp1544471pxy; Sat, 1 May 2021 17:27:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz5rDt0UBZzu/XQ6F3APufjMNIBfXK2AVIGZfHMkaJD/RbVj5BgfGP2WRGySQeBzrSIUxJV X-Received: by 2002:a17:906:704a:: with SMTP id r10mr10815714ejj.312.1619915278565; Sat, 01 May 2021 17:27:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619915278; cv=none; d=google.com; s=arc-20160816; b=jRzJu17fz9X3LKiWprAdTbcnEEtj0ZJ1KLmBFkDF25tdcCv25O9iUiXhMlxO1a32Gc z6LBqpLNhnuQFPsYyz0bJx7iwqfZt1iK2QoiAE7ERCdu/7oKGFDGGZWew7a+HIVtwInA 8UyI2HL4DfUbpXBGhVNumh7UKX3//lU3C30BZwEjQmuegi4//z1Za6h11K/ExRKy3fx4 oxn3blBzErUBqsqhUZSYXpake+Rrci0OggkeCjg7pLRkURxIaQjDiWc7DYDKEggj8wuI IzNdnQIjMEDanKvE940N/9Odwr1Zc6aLBAu5IFA4FSR4AX8F9DfjrxXr4ye9pzkJVP/9 bvhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=z9kPgoe+TFJguSOx0d+kkU5YLn+A9XKtJbjFp+0lcG0=; b=H59dYxr/XqDVgy9TJTH9enNlspF/7JGyecVVHG8gH40NFf0MAETkqELLcGXP3zj1ce z29YcgYtG43Hq+yyvKtEnnlB/KJm7Ngfw1dqWOUzYUtAQ0vgbShw5TV7BsgNIqTuxu8l A0OffQKTgjvuKqWV1WQquzwWLGprkaBmaSPI97CGNrQoknphE5IZKLWf4/RADUw+k9lU 4gamTVnhlXPgeO3aigwjeY9y19PZTKG7kfffnarlult+/rEcGFRlFj36S4D5zXMTzb+a SYL8yBi8Z+ojiDnvSWgVBPPhttrdakWxl/ebq8bhWH2Q9wAmtRUExMXIpmrdops6ddTU vzwQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w9si240916ejc.463.2021.05.01.17.27.34; Sat, 01 May 2021 17:27:58 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232151AbhEBAV2 (ORCPT + 99 others); Sat, 1 May 2021 20:21:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231877AbhEBAV2 (ORCPT ); Sat, 1 May 2021 20:21:28 -0400 X-Greylist: delayed 2549 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Sat, 01 May 2021 17:20:37 PDT Received: from vuizook.err.no (vuizook.err.no [IPv6:2a02:20c8:2640::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 74BE1C06174A for ; Sat, 1 May 2021 17:20:37 -0700 (PDT) Received: from [2400:4160:1877:2b00:fc5f:fa70:7483:1006] (helo=glandium.org) by vuizook.err.no with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lczBQ-0005em-Kb; Sat, 01 May 2021 23:38:01 +0000 Received: from glandium by goemon.lan with local (Exim 4.92) (envelope-from ) id 1lczBK-0005aQ-5j; Sun, 02 May 2021 08:37:54 +0900 Date: Sun, 2 May 2021 08:37:54 +0900 From: Mike Hommey To: Nick Desaulniers Cc: Linus Torvalds , Tom Stellard , Masahiro Yamada , Nathan Chancellor , Linux Kernel Mailing List , clang-built-linux , Fangrui Song , Serge Guelton , Sylvestre Ledru Subject: Re: Very slow clang kernel config .. Message-ID: <20210501233754.4he27eoteqvplywu@glandium.org> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-GPG-Fingerprint: 182E 161D 1130 B9FC CD7D B167 E42A A04F A6AA 8C72 User-Agent: NeoMutt/20180716 X-Spam-Status: (score 2.2): No, score=2.2 required=5.0 tests=RDNS_NONE,SPF_FAIL,SPF_HELO_FAIL autolearn=disabled version=3.4.2 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Apr 30, 2021 at 06:48:11PM -0700, Nick Desaulniers wrote: > On Fri, Apr 30, 2021 at 6:22 PM Linus Torvalds > wrote: > > > > On Fri, Apr 30, 2021 at 5:25 PM Nick Desaulniers > > wrote: > > > > > > Ah, no, sorry, these are the runtime link editor/loader. So probably > > > spending quite some time resolving symbols in large binaries. > > > > Yeah. Appended is the profile I see when I profile that "make > > oldconfig", so about 45% of all time seems to be spent in just symbol > > lookup and relocation. > > > > And a fair amount of time just creating and tearing down that huge > > executable (with a lot of copy-on-write overhead too), with the kernel > > side of that being another 15%. The cost of that is likely also fairly > > directly linked to all the dynamic linking costs, which brings in all > > that data. > > > > Just to compare, btw, this is the symbol lookup overhead for the gcc case: > > > > 1.43% ld-2.33.so do_lookup_x > > 0.96% ld-2.33.so _dl_relocate_object > > 0.69% ld-2.33.so _dl_lookup_symbol_x > > > > so it really does seem to be something very odd going on with the clang binary. > > > > Maybe the Fedora binary is built some odd way, but it's likely just > > the default clang build. > > > > Linus > > > > ---- > > 23.59% ld-2.33.so _dl_lookup_symbol_x > > 11.41% ld-2.33.so _dl_relocate_object > > 9.95% ld-2.33.so do_lookup_x > > 4.00% [kernel.vmlinux] copy_page > > 3.98% [kernel.vmlinux] next_uptodate_page > > 3.05% [kernel.vmlinux] zap_pte_range > > 1.81% [kernel.vmlinux] clear_page_rep > > 1.68% [kernel.vmlinux] asm_exc_page_fault > > 1.33% ld-2.33.so strcmp > > 1.33% ld-2.33.so check_match > > 47.61% spent in symbol table lookup. Nice. (Not counting probably a > fair amount of the libc calls below). > > > 0.92% libLLVM-12.so llvm::StringMapImpl::LookupBucketFor > > ^ wait a minute; notice how in your profile the `Shared Object` is > attributed to `libLLVM-12.so` while mine is `clang-13`? Clang can be > built as either having libllvm statically linked or dynamically; see > the cmake variables > LLVM_BUILD_LLVM_DYLIB:BOOL > LLVM_LINK_LLVM_DYLIB:BOOL > BUILD_SHARED_LIBS:BOOL > https://llvm.org/docs/CMake.html > > I think those are frowned upon; useful for cutting down on developers > iteration speed due to not having to relink llvm when developing > clang. But shipping that in production? I just checked and it doesn't > look like we do that for AOSP's build of LLVM. > > Tom, is one of the above intentionally set for clang builds on Fedora? > I'm guessing it's intentional that there are packages for > libLLVM-12.so and libclang-cpp.so.12, perhaps they have other > dependents? Have you tried building clang/llvm with -Bsymbolic-functions? Mike