www.digitalmars.com         C & C++   DMDScript  

D.gnu - Poor Performance gdc11 for base 64 with O3

reply Mahdi <ubuntulove74 gmail.com> writes:
In optimization level 3, gdc11 doesn't seem to work as well as  
gdc10 for base 64 benchmark.
On this site:
https://github.com/kostya/benchmarks#base64

, the poor performance of GDC 11 is well visible, but while 
version 10 did a good optimization.

I did a base 64 experiment on RISCV64 architecture  (other than 
Intel) with ubuntu-image:

In gdc-11(RISCV64):

      ubuntu ubuntu:~/dlang/benchmark/benchmarks/base64/gdc-11$ 
gdc-11 -O3 test.d
      ubuntu ubuntu:~/dlang/benchmark/benchmarks/base64/gdc-11$ 
time ./a.out
      encode aaaa... to YWFh...: 1431666688, 20.53
      decode YWFh... to aaaa...: 1073741824, 50.37

      real	1m11.219s
      user	1m10.793s
      sys	0m0.171s
     
______________________________________________________________________________
     In gdc-10(RISCv64):
      ubuntu ubuntu:~/dlang/benchmark/benchmarks/base64/gdc-10$ 
gdc-10 -O3 test.d
      ubuntu ubuntu:~/dlang/benchmark/benchmarks/base64/gdc-10$ 
time ./a.out
      encode aaaa... to YWFh...: 1431666688, 18.48
      decode YWFh... to aaaa...: 1073741824, 14.55

      real	0m33.447s
      user	0m33.108s
      sys	0m0.220s

source code from :
https://github.com/kostya/benchmarks/blob/master/base64/test.d
Sep 19 2021
parent reply max haughton <maxhaton gmail.com> writes:
On Sunday, 19 September 2021 at 19:04:28 UTC, Mahdi wrote:
 In optimization level 3, gdc11 doesn't seem to work as well as  
 gdc10 for base 64 benchmark.
 On this site:
 https://github.com/kostya/benchmarks#base64

 [...]
It's because of libphobos not being compiled with inlining due to the changes to template linkage emission. If you rebuild Phobos with LTO enabled (if it isn't already) you can get your performance back. Compile with LTO and try that.
Sep 19 2021
next sibling parent Mahdi <ubuntulove74 gmail.com> writes:
On Sunday, 19 September 2021 at 19:31:27 UTC, max haughton wrote:
 On Sunday, 19 September 2021 at 19:04:28 UTC, Mahdi wrote:
 In optimization level 3, gdc11 doesn't seem to work as well as 
  gdc10 for base 64 benchmark.
 On this site:
 https://github.com/kostya/benchmarks#base64

 [...]
It's because of libphobos not being compiled with inlining due to the changes to template linkage emission. If you rebuild Phobos with LTO enabled (if it isn't already) you can get your performance back. Compile with LTO and try that.
Thanks I experimented with lto but it got worse: ubuntu ubuntu:~/dlang/benchmark/benchmarks/base64/gdc-11$ gdc-11 -flto -O3 test.d ubuntu ubuntu:~/dlang/benchmark/benchmarks/base64/gdc-11$ time ./a.out encode aaaa... to YWFh...: 1431666688, 20.83 decode YWFh... to aaaa...: 1073741824, 69.34 real 1m30.447s user 1m29.369s sys 0m0.191s
Sep 20 2021
prev sibling parent Siarhei Siamashka <siarhei.siamashka gmail.com> writes:
On Sunday, 19 September 2021 at 19:31:27 UTC, max haughton wrote:
 On Sunday, 19 September 2021 at 19:04:28 UTC, Mahdi wrote:
 In optimization level 3, gdc11 doesn't seem to work as well as 
  gdc10 for base 64 benchmark.
 On this site:
 https://github.com/kostya/benchmarks#base64

 [...]
It's because of libphobos not being compiled with inlining due to the changes to template linkage emission.
Could you please tell me more about these changes? Are they somewhere in the GDC frontend, GCC backend or in the libphobos code itself? Were they intentional or a side effect of something else? Before finding this forum thread, I happened to submit a similar issue in the gcc bugzilla some days ago: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102765 What is the current status of LTO nowadays? Is it sufficiently reliable and problem-free in GDC11 to be universally recommended for any optimized release builds?
Oct 26 2021