This question is for the C geeks and linux gurus:
Recently there has been a change in the glibc-2.19 libc-2.19 library
regarding mktime.c, tzfile.c and setenv.c which has caused a major
impact to the execution time of some of my C++ programs running under
openSuse v13.2. I have seen an up to 30x increase in the time to execute
a program, necessitating a rewrite of some C++ modules, but I am still
seeing a 5x increase in execution time, whenever certain time functions
are called, such as mktime(), and localtime_r().
In particular, the unsetenv function call inside the
libc-2.19.so:setenv.c function was being called hundreds of billions of
times instead of the usual 10-100 million times for a typical program
run as some debug runs using valgrind showed.
The setenv.c source, particularly the unsetenv(const char* name) call is:
int unsetenv(name)
const char *name;
{
size_t len;
char **ep;
if (name == NULL || *name == '\0' || strchr(name,'=') != NULL)
{
__set_errno (EINVAL);
return -1;
}
len = strlen(name);
LOCK;
ep = __environ;
if ( ep != NULL )
while ( *ep != NULL )
if ( ! strncmp(*ep,name,len) && (*ep)[len] == '=' )
{
/* Found it. Remove this pointer by moving later ones back. */
char **dp = ep;
/* Continue the loop in case NAME appears again. */
}
else
++ep;
UNLOCK;
return 0;
}
Apparently according the valgrind, the code is looping 100's of billions
of times in the while loop, apparently on a non-null environment string?
I changed my code to avoid all possible calls using the timezone TZ
variable, except the bare minimum. I also called setenv to clear out all
environment variables, except TZ, which is set to a local value of
“PST8PDT”. The system etc/localtime is linked to
/usr/share/zoneinfo/America/Los_Angeles as expected.
But valgrind is still showing 40% execution time hang up in the tzfile,
unset and mktime functions and I am taking a 5x slowdown hit.
Has anyone else seen this delay in program execution time?
I really need to have the C code back up to its usual performance.
- Randall
_______________________________________________
PLUG mailing list
[email protected]
http://lists.pdxlinux.org/mailman/listinfo/plug