From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10997 invoked by alias); 11 Sep 2013 02:20:17 -0000 Mailing-List: contact glibc-bugs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: glibc-bugs-owner@sourceware.org Received: (qmail 10962 invoked by uid 48); 11 Sep 2013 02:20:12 -0000 From: "qd.feng@alcatel-lucent.com" To: glibc-bugs@sourceware.org Subject: [Bug libc/15943] New: localtime_r performance drop when set different timezone Date: Wed, 11 Sep 2013 02:20:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: glibc X-Bugzilla-Component: libc X-Bugzilla-Version: 2.12 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: qd.feng@alcatel-lucent.com X-Bugzilla-Status: NEW X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter cc Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2013-09/txt/msg00071.txt.bz2 https://sourceware.org/bugzilla/show_bug.cgi?id=15943 Bug ID: 15943 Summary: localtime_r performance drop when set different timezone Product: glibc Version: 2.12 Status: NEW Severity: normal Priority: P2 Component: libc Assignee: unassigned at sourceware dot org Reporter: qd.feng@alcatel-lucent.com CC: drepper.fsp at gmail dot com There is one thread in our application frequently call the localtime_r. We found the thread performance has 20% drop when change the timezone from the America/New_york to Asia/Shanghai from the system(Redhat 6,). After profile, we found it is the localtime_r cause the difference. When set the timezone as America/New_york, the __tzfile_compute mainly call the __tzstring. While when set the timezone as the Asia/Shanghai the __tzfile_compute call the __tzset_parse_tz which consume most of the CPU time. I also do an simple test on our HP G8 server. 1 #include 2 #include 3 4 int main(void) 5 { 6 struct tm newtime; 7 time_t ltime; 8 char buf[50]; 9 10 for(int i=0;i<=1000000;i++) 11 { 12 ltime=time(<ime); 13 14 localtime_r(<ime, &newtime); 15 } 16 } After compile and run command time ./a.out with the timezone as Asia/Shanghai or America/New_York. Asia/Shanghai real 0m1.838s user 0m1.628s sys 0m0.206s America/New_York real 0m0.608s user 0m0.395s sys 0m0.211s There is no TZ env been set on both cases. I wonder what causes the performance so difference, is it an designed behavior? Steven -- You are receiving this mail because: You are on the CC list for the bug.