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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: advise on future of glibc (mktime issue)


Jairo19@interhosting.us wrote:

Hola:

This seems to be the right mailing list for this message, please let me know otherwise.

We recently ran into some problems, and their root lies in glibc.

I will ask my questions first, then I will elaborate on the problem.

1.- What is the relationship between RedHat and glibc (besides hosting the project)?,
2.- do RH patches make it to the general glibc releases ?, does this mean that eventually other Linux distributions will get those changes ? (I think the answer to the second part is almost an obvious YES, but I have to ask)
3.- do other developers besides redhat's have the chance to review/approve RH's changes before the make it to the main tree ?



We found our problem when migrating from RH7.3 to RHEL4 and FC3. Our application slowed down significantly, a process that takes 1 day in RH7.3 now takes 3-4 days in FC3 and RHEL4.


After debugging I see the problem shows up because we call millions of times mktime (no way to avoid that for us). The patched glibc (I think by RH) has mktime checking for changes on the system's timezone, this is done by checking the file: /etc/localtime which is either a link or a copy of the local timezone file from /usr/share/zoneinfo, this is a call to the file system via stat64(), hence our program is accessing millions of times the file system and crawling in pain. The old glibc, used in RH7.3 and used in Suse Enterprise 9 does not check for changes to this file with every call to mktime.

I was able to eliminate the checks by temporarily setting TZ to GMT, but as I understand that is no longer suggested/supported, and RH7.3 was still faster.

I contacted RH and they say they will not change the behavior of their glibc because they prefer "correctness over performance" and they believe glibc should be checking for changes to the timezone. Their suggestions are: build our own glibc and loose RH support, rewrite mktime for our own use (I tried that but seemed a little complicated and looses the benefit of the library per se), and lastly they suggested to set TZ=/etc/localtime (which makes the program run a little faster, but not as fast as RH7.3).

It is widely known that FC1,2,3 and RHEL* are slow systems, and I always figured it was for the better, then I question, how may of this little changes in glibc exists in RH's patches that by themselves may not be a big performance hit, but put them together and you get a slower system ?

So our solution could be to migrate to another Linux platform, but if the changes that RH made are going to show up in the library anyway, we would be just delaying the problem.

My little and simple program that shows the performance hit (I'm leaving all the includes that my main program uses):

#include <string>
#include <vector>
#include <iostream>

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <ctime>
#include <sys/time.h>

using namespace std;

int get_dayofweek(int date)
{
 // extract day/yr/mn
 int day = date % 100;
 int month = (date % 10000) / 100;
 int year = date / 10000;

struct tm time;
time.tm_sec = 0; time.tm_min = 30; time.tm_hour = 9; time.tm_mday = day; time.tm_mon = month - 1;
time.tm_year = year - 1900;


time_t time1 = mktime(&time);

return(localtime(&(time1))->tm_wday); // Sun=0, Sat=6

} //get_dayofweek

/////////////////////////////////////////////////////
// main routine
int main(int argc, char *argv[])
{
 int today = get_dayofweek(20050115);
 for(int i=0; i<1000000;++i)
   today = get_dayofweek(20050115);

 return (1);
}

I recompiled it and time it in the same HW first running RH7.3 then running FC3, SUSE Ent9 and RHEL4.

Thanks in advance for your comments.

Hola:


Just want to thank everybody for their input in this matter, I was not expecting the workaround to my problem as it was secondary to my main issue of how changes to the glibc get propagated to other distributions (which nobody really addressed directly).


With the workaround my program now runs as expected and I no longer use mktime.

I also hope the discussion helped glibc in making mktime a little smarter by reducing the frequency it checks the file system. I am available to do some testing of this change, just let me know once it is done.


regards,



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