This is the mail archive of the libc-help@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Switch implementation based on circumstances.


On Thu, Dec 6, 2012 at 12:40 PM, OndÅej BÃlka <neleai@seznam.cz> wrote:
> Hi,
>
> I noticed that at several places we can use fast implementation most of
> time and switch to more generic one only after some function is called.

Could you use the IFUNC mechanism for this?

https://www.ibm.com/developerworks/wikis/display/LinuxP/Optimized+Libraries#OptimizedLibraries-TargetSpecific

> This mostly applies to fact that in single thread programs locking is
> not needed. I want to do something like compile file twice first time
> with locks on and second off. Then I would and hook in pthread_create+shmat
> that switches implementation.
>
> malloc, printf ... would benefit most from this one.


The problem with having a single threaded application traverse down a
non-locking path in code like malloc is that there are always the
cases of signal handler abuse.  Someone calls a function in a signal
handler that calls malloc.  But malloc was interrupted in mid-process.
So instead of getting deadlock like what happens now, you get a huge
undebuggable mess.


I'm in the camp that I don't think printf should ever been seen as a
performance path that needs improvement.  The runtime type checking
requirements introduce way too many burdens.


> Second is locale depended optimalizations where a hook for setlocale is
> needed.
>
> I do not know what is best way to collect hooks. One possibility is single
> file where you write all affected functions.

More opportunity for IFUNC.

I think when implementing some new features and writing new code that
using STM might be better than trying to have two implementations.

Ryan


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]