This is the mail archive of the libc-hacker@sources.redhat.com mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


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

iconv chache


I've been working on this for quite some time and finally took the
time to finish it.  It was item 22 in the PROJECTS file, namely, a
pre-computed cache for the iconv module database.

A few numbers for the motivation.  I've a little program which fork()s
1000 times in a loop and exec()s "/bin/echo -n".  This is one of the
simplest programs which still uses locales.  Here are the numbers
without the cache:

$ LC_ALL=C LD_LIBRARY_PATH=$PWD:$PWD/linuxthreads:$PWD/rt ./t
1000 runs of "/bin/echo": 2.318899061 secs
$ LD_LIBRARY_PATH=$PWD:$PWD/linuxthreads:$PWD/rt ./t
1000 runs of "/bin/echo": 15.541000713 secs


Pretty bad.  If you look at the sprof output you'll see that a
majority of the time is spend in the routines to parse and organize
gconv-modules.

With the changes I checked in and after running iconvconfig the result
is

$ LD_LIBRARY_PATH=$PWD:$PWD/linuxthreads:$PWD/rt ./t
1000 runs of "/bin/echo": 4.222061300 secs


I.e., the startup performance (and the initial setlocale call is
certainly startup meanwhile) improves by >300% and this even though
the remaining time includes loading the echo binary, relocate it, load
all the locale objects and the iconv module.  The difference of
1.9msec to the LC_ALL=C version is attributed to this.  I plan to do
more work on this but for now this is fine.

The iconvconfig program is easy to use.  Just run it, optionally with
additional directories containing iconv modules in the parameter list.
All the given directories are then considered all the time, no
GCONV_PATH setting necessary anymore.  The cache file is ignored in
case GCONV_PATH is set at runtime to preserve existing semantics.


The changes are quite big but only because of new code.  Modifications
to existing code is minimal and if no cache is present the code
doesn't change.  This is why I put the code in at this late time.  The
risk is minimal.

[There are a few more unrelated changes to the code which also cannot
cause disturbances.]


The iconvconfig program currently has enough functionality to support
all the modules currently provided in glibc.  It does not yet have the
full functionality the old gconv-modules handler has.  This is
intentional, to keep the possibility of errors down.  The file format
and the gconv_cache implementation should be final and for glibc 2.3
the iconvconfig program will be beefed up to support all the features.

-- 
---------------.                          ,-.   1325 Chesapeake Terrace
Ulrich Drepper  \    ,-------------------'   \  Sunnyvale, CA 94089 USA
Red Hat          `--' drepper at redhat.com   `------------------------


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