Re: Clang optimiser vs preproc.c - Mailing list pgsql-hackers

From Thomas Munro
Subject Re: Clang optimiser vs preproc.c
Date
Msg-id CA+hUKGLkSwVfSjYw=uFtt4p3-QP3R1k=4O363M+p4jj_sCM5jQ@mail.gmail.com
Whole thread Raw
In response to Re: Clang optimiser vs preproc.c  (Andres Freund <andres@anarazel.de>)
Responses Re: Clang optimiser vs preproc.c
List pgsql-hackers
On Sun, Dec 17, 2023 at 1:29 AM Andres Freund <andres@anarazel.de> wrote:
> On 2023-12-15 22:19:56 -0500, Tom Lane wrote:
> > Thomas Munro <thomas.munro@gmail.com> writes:
> > > On Sat, Dec 16, 2023 at 3:44 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
> > >> Thomas Munro <thomas.munro@gmail.com> writes:
> > >>> FYI, it looks like there is a big jump in CPU time to compile preproc.c at -O2:
> > >>> clang15: ~16s
> > >>> clang16: ~211s
> > >>> clang17: ~233s
>
> Is this with non-assert clangs? Because I see times that seem smaller by more
> than what can be explained by hardware differences:
>
> preproc.c:
> 17   10.270s
> 16    9.685s
> 15    8.300s
>
> gram.c:
> 17    1.936s
> 16    2.131s
> 15    2.161s
>
> That's still bad, but a far cry away from 233s.

Hrmph.  Well something weird is going on, but it might indeed involve
me being confused about debug options of the compiler itself.  How can
one find out which build options were used for clang/llvm compiler +
libraries?  My earlier reports were from a little machine at home, so
let's try again on an i9-9900 CPU @ 3.10GHz (a bit snappier) running
Debian 12, again using packages from apt.llvm.org:

17 ~198s
16 ~14s
15 ~11s

OK so even if we ignore the wild outlier it is getting significantly
slower.  But... huh, there goes the big jump, but at a different
version than I saw with FBSD's packages.   Here's what perf says it's
doing:

+   99.42%    20.12%  clang-17  libLLVM-17.so.1      [.]
llvm::slpvectorizer::BoUpSLP::getTreeCost
                                                           ◆
+   96.91%     0.00%  clang-17  libLLVM-17.so.1      [.]
llvm::SLPVectorizerPass::runImpl
                                                           ▒
+   96.91%     0.00%  clang-17  libLLVM-17.so.1      [.]
llvm::SLPVectorizerPass::vectorizeChainsInBlock
                                                           ▒
+   96.91%     0.00%  clang-17  libLLVM-17.so.1      [.]
llvm::SLPVectorizerPass::vectorizeSimpleInstructions
                                                           ▒
+   96.91%     0.00%  clang-17  libLLVM-17.so.1      [.]
llvm::SLPVectorizerPass::vectorizeInsertElementInst
                                                           ▒
+   96.91%     0.00%  clang-17  libLLVM-17.so.1      [.]
llvm::SLPVectorizerPass::tryToVectorizeList
                                                           ▒
+   73.79%     0.00%  clang-17  libLLVM-17.so.1      [.]
0x00007fbead445cb0
                                                           ▒
+   36.88%    36.88%  clang-17  libLLVM-17.so.1      [.]
0x0000000001e45cda
                                                           ▒
+    3.95%     3.95%  clang-17  libLLVM-17.so.1      [.] 0x0000000001e45d11



pgsql-hackers by date:

Previous
From: Nathan Bossart
Date:
Subject: Re: add non-option reordering to in-tree getopt_long
Next
From: Peter Smith
Date:
Subject: Re: Synchronizing slots from primary to standby