This is the mail archive of the
mailing list for the glibc project.
Re: Switch implementation based on circumstances.
- From: "Ryan S. Arnold" <ryan dot arnold at gmail dot com>
- To: OndÅej BÃlka <neleai at seznam dot cz>
- Cc: libc-help <libc-help at sourceware dot org>
- Date: Thu, 6 Dec 2012 12:44:04 -0600
- Subject: Re: Switch implementation based on circumstances.
- References: <20121206184042.GA29990@domone.kolej.mff.cuni.cz>
On Thu, Dec 6, 2012 at 12:40 PM, OndÅej BÃlka <email@example.com> wrote:
> 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?
> 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
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
> 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.