public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* Speed my reducing relocations
@ 2021-07-11 15:08 Tom Kacvinsky
  2021-07-11 17:39 ` Fangrui Song
  0 siblings, 1 reply; 4+ messages in thread
From: Tom Kacvinsky @ 2021-07-11 15:08 UTC (permalink / raw)
  To: Binutils

I was reading

https://gist.github.com/MaskRay/2d4dfcfc897341163f734afb59f689c6

And there, they say there are ways of increasing performance via compiler
options (-fno-semantic-interposition) and linker options (-Bsymbolic), but
I just
don't seen the benefit of using these with GCC 8.3.0 and binutils 2.34.
Most of
it seems to be clang specific, with LLVM linker), but there is a section on
how
to do this with GCC.

Any ideas on what I can do to make things better?

Thanks,

Tom

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Speed my reducing relocations
  2021-07-11 15:08 Speed my reducing relocations Tom Kacvinsky
@ 2021-07-11 17:39 ` Fangrui Song
  2021-07-12 15:26   ` Florian Weimer
  0 siblings, 1 reply; 4+ messages in thread
From: Fangrui Song @ 2021-07-11 17:39 UTC (permalink / raw)
  To: Tom Kacvinsky; +Cc: Binutils

On 2021-07-11, Tom Kacvinsky via Binutils wrote:
>I was reading
>
>https://gist.github.com/MaskRay/2d4dfcfc897341163f734afb59f689c6

I split it into two articles.

>And there, they say there are ways of increasing performance via compiler
>options (-fno-semantic-interposition) and linker options (-Bsymbolic), but
>I just
>don't seen the benefit of using these with GCC 8.3.0 and binutils 2.34.
>Most of
>it seems to be clang specific, with LLVM linker), but there is a section on
>how
>to do this with GCC.
>
>Any ideas on what I can do to make things better?
>
>Thanks,
>
>Tom

-fno-semantic-interposition mainly benefits GCC, which suppress interprocedural
optimizations including inlining for external linkage functions.
You need an application which needs speedup from interprocedural optimizations,
e.g. Clang 13.0.0 (3% on some benchmarks), CPython (27% on some workload).

Two folks like the GCC behavior
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100937
But Clang will stay its current behavior: allow interprocedural optimizations
unless -fsemantic-interposition is explicitly specified.

(https://fedoraproject.org/wiki/Changes/PythonNoSemanticInterpositionSpeedup
used to be utterly wrong about the implications.  I provided the updated
wording.)


The dynamic relocation reducing is mostly -Bsymbolic/-Bsymbolic-functions's job.
-fno-semantic-interposition only helps for function definitions not referenced
by other translation units, so its effect is tiny.


I have an ambitious plan
https://maskray.me/blog/2021-05-16-elf-interposition-and-bsymbolic#the-last-alliance-of-elf-and-men
but it really requires GCC/binutils folks' cooperation.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Speed my reducing relocations
  2021-07-11 17:39 ` Fangrui Song
@ 2021-07-12 15:26   ` Florian Weimer
  2021-07-13  0:32     ` Fangrui Song
  0 siblings, 1 reply; 4+ messages in thread
From: Florian Weimer @ 2021-07-12 15:26 UTC (permalink / raw)
  To: Fangrui Song; +Cc: Tom Kacvinsky, Binutils

* Fangrui Song:

> -fno-semantic-interposition only helps for function definitions not
> referenced by other translation units, so its effect is tiny.

Is this Clang-specific?

With -flto, GCC switches to hidden aliases for internal calls with -flto
(and a linker plugin).  This enables all kinds of other optimizations,
and not all of that can be done by -Bsymbolic-functions.  Especially on
targets that aren't like x86-64.

Thanks,
Florian


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Speed my reducing relocations
  2021-07-12 15:26   ` Florian Weimer
@ 2021-07-13  0:32     ` Fangrui Song
  0 siblings, 0 replies; 4+ messages in thread
From: Fangrui Song @ 2021-07-13  0:32 UTC (permalink / raw)
  To: Florian Weimer; +Cc: Tom Kacvinsky, Binutils

On 2021-07-12, Florian Weimer wrote:
>* Fangrui Song:
>
>> -fno-semantic-interposition mainly benefits GCC, which suppress
>> interprocedural
>> optimizations including inlining for external linkage functions.
>> You need an application which needs speedup from interprocedural
>> optimizations,
>> e.g. Clang 13.0.0 (3% on some benchmarks), CPython (27% on some workload).
>> The dynamic relocation reducing is mostly -Bsymbolic/-Bsymbolic-functions's job.
>> -fno-semantic-interposition only helps for function definitions not
>> referenced by other translation units, so its effect is tiny.
>
>Is this Clang-specific?
>
>With -flto, GCC switches to hidden aliases for internal calls with -flto
>(and a linker plugin).  This enables all kinds of other optimizations,
>and not all of that can be done by -Bsymbolic-functions.  Especially on
>targets that aren't like x86-64.

My point still stands: -fno-semantic-interposition mainly benefits GCC.

Regarding R_*_JUMP_SLOT relocations:

-fno-semantic-interposition replaces call targets with STB_LOCAL
aliases. If a default visibility external linkage function is ever
called without a STB_LOCAL alias, there will be a JUMP_SLOT in -shared
mode if the symbol is not made preemptible by other means
(--version-script local:, --dynamic-list, etc).

In this sense, -fno-semantic-interposition does help clang -flto and gcc
-flto, by decreasing JUMP_SLOT. -Bsymbolic-functions can do the same on
most modern architectures.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-07-13  0:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-11 15:08 Speed my reducing relocations Tom Kacvinsky
2021-07-11 17:39 ` Fangrui Song
2021-07-12 15:26   ` Florian Weimer
2021-07-13  0:32     ` Fangrui Song

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).