Re: Gcc version affects program execution efficiency

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

Version 9.4 is quite old - from <https://gcc.gnu.org/> you can see that gcc 11.4 is the oldest version still actively supported by the gcc development team. Ubuntu, or their upstream source Debian, might still support older gcc. So there are limits to how much help you can get here - basically, you get people like me (a user) giving you suggestions on how to find out more yourself.

That said, if there is a significant regression here, it's possible that it also applies to newer gcc, and therefore be important to identify, and if it turns out to be a real and current performance regression, you can file a bug for the experts to consider.

The first thing to do in cases like this is to make sure you have a sensible choice of compiler options (such as optimisation flags) and that they are the same for both compilers.

The next step is to isolate a compilable stand-alone version of the function. That does not take much here, but it needs a little - a typedef for uint_8, and some kind of definition for SOFO and COM (I have no idea what these should be).

Then put the code into the fantastic site <https://godbolt.org>, and compare versions. I've made a start here:

<https://godbolt.org/z/EfGY96v39>

From here, we can quickly see that the current trunk gcc generates the same code (at -O2) as for 9.4, and that this is noticeably different from gcc 7.5. It is also easy to check that the gcc 8 series generates the same code as 7.5, so this has been affected by a change made between gcc 7 and gcc 8.

It is not at all easy to know what speed differences there are between these code versions. So this is something /you/ can do - measure the speed of this function with gcc 7.5 and 9.4, to see what difference you are seeing in practice. (And when giving the results, include brief information about the processor.)

Now with the generated code easily visible, someone with more experience than me at x86_64 and the code generation (especially changes between gcc 8 and 9) can maybe see what's going on, and whether or not it is a problem.

David




On 27/02/2024 14:44, abzhou36 via Gcc-help wrote:
Dear Sir or Madam




I used ffmpeg for hardware acceleration of video decoding and compiled ffmpeg using gcc-9.4 on the Ubuntu 20.04 system.
However, its performance is poor. If gcc-7.5 is used on the same Ubuntu 20.04 system, the decoding performance will be better.


I analyzed the code of ffmpeg and found that there is a big difference in time consumption when use gcc-9.4 and gcc-7.5 in the following functions:
static int find_marker(const uint_8 **pbuf_ptr, const uint_8 *buf_end)
{
     const uint_8 *buf_ptr;
     unsigned int v, v2;
     int val;
     int skipped = 0;
buf_ptr = *pbuf_ptr;
     while (buf_end - buf_ptr > 1) {
         v = *buf_ptr++;
         v2 = *buf_ptr;
         if (v == 0xff && v2 >= SOFO && v2 <= COM) {
             val = *buf_ptr++;
              goto found;
         }
         skipped++;
     }
     buf_ptr = buf_end;
     val = -1;
found:
     *pbuf_ptr = buf_ptr;
     return val;
}


I want to know why this difference arises and how to solve this problem.


I look forward to your help.


Thanks and Regards.
Aibin




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux