From patchwork Tue Dec 18 07:12:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: ma.jiang@zte.com.cn X-Patchwork-Id: 30717 Received: (qmail 103091 invoked by alias); 18 Dec 2018 07:12:37 -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 103076 invoked by uid 89); 18 Dec 2018 07:12:36 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: =?ISO-8859-1?Q?No, score=-16.4 required=5.0 tests=BAYES_00, BODY_8BITS, GARBLED_BODY, GARBLED_SUBJECT, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS, UNPARSEABLE_RELAY autolearn=ham version=3.3.2 spammy=wise, savings, 18=e6, BZ?= X-HELO: mxct.zte.com.cn Date: Tue, 18 Dec 2018 15:12:25 +0800 (CST) X-Zmail-TransId: 2b085c189dd92fe52ad1 Message-ID: <201812181512254503522@zte.com.cn> In-Reply-To: References: 201812172006103612868@zte.com.cn, a5283871-3b8b-9816-8f3b-044f3dd2ffa1@redhat.com Mime-Version: 1.0 From: To: Cc: , , Subject: =?UTF-8?B?UmU6W1BBVENIXSDCoMKgdHpzZXQgZGlkIG5vdCBjYXRjaCBjaGFuZ2VzIHRvbG9jYWx0aW1lwqAgW0JawqAjMjEwNjDCoF0=?= X-MAIL: mse02.zte.com.cn wBI7CNa2083984 I agree that we should make more effort to avoid the costly file system operations(as the test shows a 10x slowdown). It's certainly not wise to pay a 10x slowdown to detect changes that probably never happen. But it seems very difficult to keep tzset things run fast and correctly... A simple solution might be to add a new interface that does not reload tzdata. By the way, there is another small problem. When TZ is not set, tzset will get into __tzfile_read everytime, and become very slow. If we do not care tzdata changes, and want a fast tzset, we could do a simple swap as following. ------------------原始邮件------------------ 发件人:CarlosO'Donell 收件人:Paul Eggert ;马江10100629;schwab@suse.de ; 抄送人:libc-alpha@sourceware.org ; 日 期 :2018年12月18日 12:24 主 题 :Re: [PATCH] tzset did not catch changes tolocaltime [BZ #21060 ] On 12/17/18 5:23 PM, Paul Eggert wrote: > I followed up in the bug report, here: > > https://sourceware.org/bugzilla/show_bug.cgi?id=21060#c1 > In the case of reloading if TZ or /etc/localtime has changed we are in the same realm of problem as /etc/resolv.conf reloading, it's something we would like to be able to do, but you're going to need more cleverness to avoid the costly operations, otherwise it's lost performance for little to no gain. Most developers don't change /etc/localtime, and in many countries it is a stable set of daylight savings transitions (and if they change you need to restart). The naive implementation is not going to be sufficient. --- Cheers, Carlos. diff --git a/time/tzset.c b/time/tzset.c index b517867..94ae747 100644 --- a/time/tzset.c +++ b/time/tzset.c @@ -386,15 +386,15 @@ tzset_internal (int always) if (tz && *tz == ':') ++tz; + if (tz == NULL) + /* No user specification; use the site-wide default. */ + tz = TZDEFAULT; + /* Check whether the value changed since the last run. */ if (old_tz != NULL && tz != NULL && strcmp (tz, old_tz) == 0) /* No change, simply return. */ return; - if (tz == NULL) - /* No user specification; use the site-wide default. */ - tz = TZDEFAULT; - tz_rules[0].name = NULL; tz_rules[1].name = NULL;