Live data from Hacker News

Boosting zopfli performance

roartindon.blogspot.com

11–14 of 14 posts

Re: Boosting zopfli performance

#11
post #4

Very interesting, unfortunately he doesn't say if he has submitted these improvements to the upstream developers so that other users of zopfli will benefit from them.

Hi, author of the article here.

Yes, talking to Lode (from Google) about getting the changes into the main development branch.

Re: Boosting zopfli performance

#12
For the change to reorder the additions to add int-to-int and float-to-float to remove one conversion, I wonder if the compiler would do that itself if allowed to by -ffast-math (included in -Ofast)? Normally, the compiler cannot (even with -O3) perform changes that might change exact floating-point results.

EDIT: No, looks like gcc can't do this even with -ffast-math or -Ofast. Given the following C code:

    double test1(int lbits, double lsym, int dbits, double dsym)
    {
        return lsym + lbits + dsym + dbits;
    }

    double test2(int lbits, double lsym, int dbits, double dsym)
    {
        return lbits + dbits + lsym + dsym;
    }
GCC, with either -O3 or -Ofast, with or without -ffast-math, always produces two cvtsi2sd instructions for test1 and one cvtsi2sd instruction for test2.

Filed as a GCC feature request: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70731

Re: Boosting zopfli performance

#13

For the change to reorder the additions to add int-to-int and float-to-float to remove one conversion, I wonder if the compiler would do that itself if allowed to by -ffast-math (included in -Ofast)? Normally, the compiler cannot (even with -O3) perform changes that might change exact floating-point results. EDIT: No, looks like gcc can't do this even with -ffast-math or -Ofast. Given the following C code: double tes…

Hi, author of article here.

I tested -ffast-math on clang and it won't reorder the additions to omit the conversion here.

I'm actually VERY wary of -ffast-math due to a bad experience some years ago where it just totally messed up my calculations and I couldn't avoid it messing up my calculations.

Even a 1ulp change (not accounting for the round down) in the final floating point comparison changed my compression results; so I'm not entirely confident about using -ffast-math without a huge test corpus -- but turning it on does improve the run time.

Re: Boosting zopfli performance

#14
post #2

Is if (costs[j+k] - costs[j] really the same as if (costs[j+k] even with floating point math?

This is a good question. I pondered about it myself.

I could prove that a - b would result in first being true, 2nd being false)

But I couldn't think of a failure case for a - b Would love it if someone could verify/prove this.

To further complicate it, the LHS of the code in question is a float evaluation, that is then upcast to a double to compare with the right (which is a double).

Post reply on HN