Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp847261pxy; Fri, 30 Apr 2021 18:49:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyIsiiETIPOADcLFYa8KpM2VJAuoWE90JebYs5wxwiU/fcgIVSevrtjHbnXUqkvk1u+1fos X-Received: by 2002:a62:7f84:0:b029:25f:b701:38e5 with SMTP id a126-20020a627f840000b029025fb70138e5mr7581196pfd.5.1619833749093; Fri, 30 Apr 2021 18:49:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619833749; cv=none; d=google.com; s=arc-20160816; b=vCL/dyeLJYOxLDorDE3kZCHc1UwUSpNaj0br25m7gbo2i+hTC0J5m2UOmHoeW6OR93 nnnc0FRRbpzacKSz60EG9aYFyDJOzW+uDVbQZ9a6KNqE2KHNqLxU5dENSF5aKaJMg+cq eP9WEJEJfzaTdlCNtqv/iPl+YjAogfTkJTLG9jzK/DPzwQhBemadXHFs3tBMzVTWg5fG zs2xuUkKdwVETUoXQ+Sp5bnmgGXlsmnHaG9CI6uhrq0fK/HJLBigiWDVTA7Udl/WxfKH 2kpF+mlk3fiNyO5dH6G74fBatYG20Wv4OaNDzLr0tSaQrOanXpJGGaHAvh2oTVXegG7F pzkQ== 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=eBtHrA9yJb6BkyPbvCe4U6uwAdzA/QThsJuomereZNw=; b=Hb5rfwfggNbP2XwSzWl5sAS5h12b/InA2tEQ8tWQdMgZvZceGxNn8EBkQLMI7JVnHq 3L377sHpNHRm9qEdV1FaHxVsD9VAQBli4+kSqBD83e7FO/JW6zKMyRZkQqNFgj//B+mN kiO6XkWXVbdLvM7CrX7tz4iOkqH+7ssCgMMNHNzMYHHlQ5oem9E/8nqgdd/2cQ+j5mKu mxbfLdd3LiCEhwYggn9fC7crFEgn5d5rH/HM/0woE9TS6TFsiFzKz/Qo2PDcB8nt2bXz FFdCYaD3tNX/8Fe7CKTN5J6yJeUSdwyp8oDzNTZVX2Lauzfce9DtVt54sWcLZRiu0I77 q4jQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=tF2MeLtO; 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 j3si3909909pfh.174.2021.04.30.18.48.55; Fri, 30 Apr 2021 18:49:09 -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=tF2MeLtO; 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 S231298AbhEABtO (ORCPT + 99 others); Fri, 30 Apr 2021 21:49:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230508AbhEABtO (ORCPT ); Fri, 30 Apr 2021 21:49:14 -0400 Received: from mail-lf1-x12f.google.com (mail-lf1-x12f.google.com [IPv6:2a00:1450:4864:20::12f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 04EB5C06174A for ; Fri, 30 Apr 2021 18:48:24 -0700 (PDT) Received: by mail-lf1-x12f.google.com with SMTP id x2so6952785lff.10 for ; Fri, 30 Apr 2021 18:48:24 -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=eBtHrA9yJb6BkyPbvCe4U6uwAdzA/QThsJuomereZNw=; b=tF2MeLtOeGN1CstFmVV4GWgQ2IPf2Kz1Syz+1idJe+MlI71IFJvPWpk6kgirsYfgnP MmGy6rxVciXgZvdfAO0mbflK25f16F3378MQapANn/NROJ7DZImWZT2Bi0kBB8P9kh+K RgDjiJ3FPb6QZNqvFM07TrqvRIL8XsoMfBOvar287KvyPOr0NQIWNELm51QLvFAkHLPl wpkHqI4wbmaBzRm8pTdJJSEfstbwi9scOKAB8cycN5mJYg3n0Vu3l98J7niZ19EXz/06 G4GSGeaSsvldYyyORmbCYrDe3MnLNBAbzcxkoH3LgB7OrDxWI67ofEQBE4Ly6LfqVrMm YbDA== 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=eBtHrA9yJb6BkyPbvCe4U6uwAdzA/QThsJuomereZNw=; b=HZM7J1eoSVidjFfWd1HurAox4vL1y58Goghuqz4ByE0szrEwL79AXoc9nf3jXo3O9c 8VnOXel5sRIiwmBfUILAqd63dL2aKN9eV1iY+fhRjdkeI+EWRsX2HCnotwX6fX6+bvH8 tGd19tNJxm2o7Oj/l5MHleJY9LyXfmAjMO5bioJXWETCDdpLRehXSS9xwhXd0SzDLYLg 3ORjWihJQiJGVzOoiTPb+EvuI9NNo01x+gp96jStljJzVWEg6+uEtbB6knxEHcFXoIUP oSwrNqo0YPj02wnDjjfXHgGssZiSYDXj+hg2KIzi/vuvVdkqXPJHCbqFaVExjcWBiVWP wdkA== X-Gm-Message-State: AOAM531A8fG/6zWRY5OAHIqXkDcUg9dTaUt+os/v9wYZSEcWI5YlGnIa GaaIfuzLdOkBOIUkx8PDOCFU2LS7Okxuu8Dbrkgxww== X-Received: by 2002:a05:6512:2190:: with SMTP id b16mr5235875lft.122.1619833703046; Fri, 30 Apr 2021 18:48:23 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Nick Desaulniers Date: Fri, 30 Apr 2021 18:48:11 -0700 Message-ID: Subject: Re: Very slow clang kernel config .. To: Linus Torvalds , Tom Stellard Cc: Masahiro Yamada , Nathan Chancellor , Linux Kernel Mailing List , clang-built-linux , Fangrui Song , Serge Guelton , Sylvestre Ledru Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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? > 0.83% [kernel.vmlinux] rmqueue_bulk > 0.77% conf yylex > 0.75% libc-2.33.so __gconv_transform_utf8_internal > 0.74% libc-2.33.so _int_malloc > 0.69% libc-2.33.so __strlen_avx2 > 0.62% [kernel.vmlinux] pagecache_get_page > 0.58% [kernel.vmlinux] page_remove_rmap > 0.56% [kernel.vmlinux] __handle_mm_fault > 0.54% [kernel.vmlinux] filemap_map_pages > 0.54% libc-2.33.so __strcmp_avx2 > 0.54% [kernel.vmlinux] __free_one_page > 0.52% [kernel.vmlinux] release_pages -- Thanks, ~Nick Desaulniers