[PATCH 0/1] MR10350: server: Cache timezone bias adjustment in set_user_shared_data_time().
From: Paul Gofman <pgofman@codeweavers.com> --- server/fd.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/server/fd.c b/server/fd.c index 4c0aa36d359..efb6e8e76b9 100644 --- a/server/fd.c +++ b/server/fd.c @@ -379,7 +379,8 @@ static void atomic_store_long(volatile LONG *ptr, LONG value) static void set_user_shared_data_time(void) { timeout_t tick_count = monotonic_time / 10000; - static timeout_t last_timezone_update; + static timeout_t last_timezone_update, last_timezone_bias = 65535, adjusted_timezone_bias; + static int current_year = -1; timeout_t timezone_bias; struct tm *tm, tm1, tm2; time_t now; @@ -390,13 +391,19 @@ static void set_user_shared_data_time(void) tm = gmtime( &now ); timezone_bias = mktime( tm ) - now; tm = localtime( &now ); - if (tm->tm_isdst) + if (current_year != tm->tm_year || last_timezone_bias != timezone_bias) { - tm1 = tm2 = *tm; - tm1.tm_isdst = 0; - tm2.tm_isdst = 1; - timezone_bias += mktime(&tm1) < mktime(&tm2) ? 3600 : -3600; + current_year = tm->tm_year; + last_timezone_bias = adjusted_timezone_bias = timezone_bias; + if (tm->tm_isdst) + { + tm1 = tm2 = *tm; + tm1.tm_isdst = 0; + tm2.tm_isdst = 1; + adjusted_timezone_bias += mktime(&tm1) < mktime(&tm2) ? 3600 : -3600; + } } + timezone_bias = adjusted_timezone_bias; timezone_bias *= TICKS_PER_SEC; atomic_store_long(&user_shared_data->TimeZoneBias.High2Time, timezone_bias >> 32); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10350
As discovered in https://gitlab.winehq.org/wine/wine/-/merge_requests/10348 / https://bugs.winehq.org/show_bug.cgi?id=59514 , mktime() with switched tm_isdst takes a long time to execute. This patch introduces the same logic as in ntdll's get_timezone_info() to guess that timezone / timezone bias has not changed and avoids the expensive adjustment in this case. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10350#note_132377
participants (2)
-
Paul Gofman -
Paul Gofman (@gofman)