svn commit: r227753 - in head: contrib/gdtoa include lib/libc/gdtoa lib/libc/gen lib/libc/locale lib/libc/regex lib/libc/stdio lib/libc/stdlib lib/libc/stdtime lib/libc/string

David Chisnall theraven at FreeBSD.org
Mon Jan 30 19:05:18 UTC 2012


On 18 Jan 2012, at 19:07, David Schultz wrote:

> This patch appears to cause a large performance regression.  For
> example, I measured a 78% slowdown for strtol("    42", ...).

That's definitely worth taking a closer look at.  I think we can cache some things in TLS and avoid some pthread_getspecific calls.  The current code is the 'make it work' version.  The 'make it fast' version is planned...

> Furthermore, the resulting static binary for a trivial program
> goes from 7k to 303k, due to pulling in malloc, stdio, and all the
> pthread stubs.  

That's not ideal, but I'm not sure if it's avoidable.  Is statically linking libc something people regularly do?

> Presumably the capabilities of the non-xlocale
> entry points aren't appreciably changed,

Well... actually they are.  All of them now use the per-thread locale if one is set, and only fall back to the global one if it isn't.  The behaviour is only unchanged if nothing in the program calls uselocale().

> so there ought to be a
> way to avoid the overhead for them.  Do you have any thoughts on this?

Yup.  A quick-and-dirty hack would be to add a flag that was set on the first call to uselocale() and to always use the global locale if this is not set.  That should remove a lot of the overhead in cases where no one uses the per-thread locales.  

We can also probably store the locale in TLS, which (on platforms with fast TLS) should speed up the lookup a bit.  

> Some more minor issues...
> 
> It's also customary to document public APIs so that, for
> instance, `man printf_l' pulls up a page with the prototype,
> required #includes, and behavior.  Aliasing manpages with
> MLINKS as appropriate is fine; for instance, Darwin's manpages
> on these functions look like a good example to follow.

Yup, all of the foo_l manpages are missing.  They're on my TODO, unless any docs people want to get there first...

> Finally, I'm not usually one to be picky about style, but could
> you make a pass to clean things up a little bit to match the
> surrounding code, wrap multiline comments to 80 columns, etc?
> You've also added new copyright notices for one-line changes
> (e.g., stdio/vdprintf.c, gdtoa/machdep_ldis?.c) and multiple
> copyright notices in the same file (locale/collate.c), which
> could be cleaned up concurrently.

I'll take a look.

David


More information about the svn-src-all mailing list