On Thu, Mar 28, 2019 at 10:38 AM Christoph Berg <m...@debian.org> wrote:
> Re: Ants Aasma 2019-03-27 < > ca+csw_twxdrzdn2xsszbxej63dez+f6_hs3qf7hmxfenxsq...@mail.gmail.com> > > Can you try with postgres compiled with CFLAGS="-O2 -march=native"? > There's > > a bit of low hanging fruit there to use a runtime CPU check to pick a > > better optimized checksum function. > > Frankly, no. This is with the apt.pg.o packages which are supposed to > be usable by everyone. If there is a better per-CPU checksum function, > PG should pick it at runtime. Special compiler flags are a no-go here. > I went ahead and tested it on the count(*) test, same settings as upthread. Median of 5 runs of 20txs on Intel i5-2500k @ 4GHz. No checksum: 344ms Checksums: 384ms (+12%) No checksum march=native: 344ms Checksums march=native: 369ms (+7%) The checksum code was written to be easily auto-vectorized by the compiler. So if we just compile the same function with different compiler flags and pick between them at runtime the overhead can be approximately halved. Not saying that this needs to be done before enabling checksums by default, just that when considering overhead, we can foresee it being much lower in future versions. Regards, Ants Aasma