Re: Clang optimiser vs preproc.c

From: Thomas Munro <thomas(dot)munro(at)gmail(dot)com>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Clang optimiser vs preproc.c
Date: 2023-12-18 22:42:20
Message-ID: CA+hUKGLkSwVfSjYw=uFtt4p3-QP3R1k=4O363M+p4jj_sCM5jQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sun, Dec 17, 2023 at 1:29 AM Andres Freund <andres(at)anarazel(dot)de> wrote:
> On 2023-12-15 22:19:56 -0500, Tom Lane wrote:
> > Thomas Munro <thomas(dot)munro(at)gmail(dot)com> writes:
> > > On Sat, Dec 16, 2023 at 3:44 PM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> > >> Thomas Munro <thomas(dot)munro(at)gmail(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Smith 2023-12-18 23:20:43 Re: Synchronizing slots from primary to standby
Previous Message Nathan Bossart 2023-12-18 21:52:01 Re: add non-option reordering to in-tree getopt_long