From patchwork Wed Feb 11 13:37:19 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Easton X-Patchwork-Id: 5043 Received: (qmail 25464 invoked by alias); 11 Feb 2015 12:37:49 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 25439 invoked by uid 89); 11 Feb 2015 12:37:49 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=1.7 required=5.0 tests=BAYES_05, TO_NO_BRKTS_PCNT autolearn=no version=3.3.2 X-HELO: chicago.guarana.org Date: Thu, 12 Feb 2015 00:37:19 +1100 From: Kevin Easton To: libc-alpha@sourceware.org Subject: [PATCH][BZ #16145] Reduce lock contention in __tz_convert() Message-ID: <20150211133719.GA19495@chicago.guarana.org> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) This patch is an "easy win" partial fix for BZ #16145, which notes the heavy contention on tzset_lock when multiple threads are converting times with localtime_r(). In __tz_convert(), the lock does not need to be held after __tzfile_compute() / __tz_compute() have been called, so we can move the unlock up. At this point there is still significant work to be done in __offtime(), so we see some improvement (in my testing with 8 cores banging on localtime_r(), ~20% improvement in throughput). [BZ #16145] (partial fix) * time/tzset.c (__tz_convert): Unlock tzset_lock earlier to reduce lock contention. diff --git a/time/tzset.c b/time/tzset.c index 8bc7a2e..82324ca 100644 --- a/time/tzset.c +++ b/time/tzset.c @@ -644,6 +644,8 @@ __tz_convert (const time_t *timer, int use_localtime, struct tm *tp) leap_extra_secs = 0; } + __libc_lock_unlock (tzset_lock); + if (tp) { if (! use_localtime) @@ -659,8 +661,6 @@ __tz_convert (const time_t *timer, int use_localtime, struct tm *tp) tp = NULL; } - __libc_lock_unlock (tzset_lock); - return tp; }