public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: David Brown <david.brown@hesbynett.no>
To: abzhou36 <abzhou36@163.com>, gcc-help@gcc.gnu.org
Subject: Re: Gcc version affects program execution efficiency
Date: Tue, 27 Feb 2024 17:21:29 +0100	[thread overview]
Message-ID: <0d7e9daf-062b-123a-9a7c-d9e9b2227947@hesbynett.no> (raw)
In-Reply-To: <588501a5.1197e.18deacf4429.Coremail.abzhou36@163.com>

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


      reply	other threads:[~2024-02-27 16:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-27 13:44 abzhou36
2024-02-27 16:21 ` David Brown [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0d7e9daf-062b-123a-9a7c-d9e9b2227947@hesbynett.no \
    --to=david.brown@hesbynett.no \
    --cc=abzhou36@163.com \
    --cc=gcc-help@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).