Re: [PATCH v2 07/13] asm-generic: unaligned always use struct helpers

From: Eric Biggers
Date: Tue May 18 2021 - 17:31:17 EST


On Tue, May 18, 2021 at 10:51:23PM +0200, Arnd Bergmann wrote:
>
> > zstd looks very similar to lz4.
>
> > End result: at a minimum, I'd suggest using
> > "-fno-tree-loop-vectorize", although somebody should check that NEON
> > case.
>
> > And I still think that using O3 for anything halfway complicated
> > should be considered odd and need some strong numbers to enable.
>
> Agreed. I think there is a fairly strong case for just using -O2 on lz4
> and backport that to stable.
> Searching for lz4 bugs with -O3 also finds several reports including
> one that I sent myself:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65709
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69702
>
> I see that user space zstd is built with -O3 in Debian, but it the changelog
> also lists "Improved : better speed on clang and gcc -O2, thanks to Eric
> Biggers", so maybe Eric has some useful ideas on whether we should
> just use -O2 for the in-kernel version.
>

In my opinion, -O2 is a good default even for compression code. I generally
don't see any benefit from -O3 in compression code I've written.

That being said, -O2 is what I usually use during development. Other people
could write code that relies on -O3 to be optimized well.

The Makefiles for lz4 and zstd use -O3 by default, which is a little concerning.
I do expect that they're still well-written enough to do well with -O2 too, but
it would require doing benchmarks to tell for sure. (As Arnd noted, it happens
that I did do such benchmarks on zstd about 5 years ago, and I found an issue
where some functions weren't marked inline when they should be, causing them to
be inlined at -O3 but not at -O2. That got fixed.)

- Eric