Re: NLS/strerror efficiency

From: Peter Jeremy <peterjeremy_at_acm.org>
Date: Sun, 24 Jan 2010 20:19:11 +1100
On 2010-Jan-23 20:34:35 +0100, Gabor Kovesdan <gabor_at_FreeBSD.org> wrote:
>I have a fix for msgcat.c to optimalize catalog handling. As I'm not an 
>src committer, delphij_at_ is helping me in reviewing and approving my 
>patches. I've sent the attached patch to him today and I'm waiting for 
>his response now. This patch caches the failing and the succesful 
>catopen() calls in a thread-safe way and in the latter case it counts 
>references to cached catalog.

I think this is a good start but still needs some work.  One issue is
that the patch mixes whitespace changes (some not complying with
style(9)) and functional changes.  This makes it harder to see the
functional changes.

On 2010-Jan-23 21:38:35 +0200, Kostik Belousov <kostikbel_at_gmail.com> wrote:
>Wouldn't this cause the locale for error strings to be fixated at the
>time of the first strerror/gai_strerror call ?

Yes.

>Current code, despite it inefficiency, allow dynamic change of locale
>that is reflected in strerror() output, I believe.

How much of an issue is this in reality?  There are two cases to
consider:
1) A process that dynamically changes its locale.
2) Locale files being updated whilst the process is running.

The first can be worked around by also caching the current locale
and checking that it hasn't changed.

The second is more problematic - particularly for long-running
programs.  Maybe add a timestamp and re-check every minute or 5.

-- 
Peter Jeremy

Received on Sun Jan 24 2010 - 08:19:19 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:00 UTC