Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(55)

Issue 2726253002: [date] Add a cache for timezone names to DateCache (Closed)

Created:
3 years, 9 months ago by Dan Ehrenberg
Modified:
3 years, 9 months ago
CC:
v8-reviews_googlegroups.com, yangguo, jgruber, Benedikt Meurer
Target Ref:
refs/pending/heads/master
Project:
v8
Visibility:
Public.

Description

[date] Add a cache for timezone names to DateCache To speed up Date.prototype.toString(), this patch adds a cache in the DateCache for the string short name representing the time zone. Because time zones in a particular location just have two short names (for DST and standard time), and the DateCache already understands whether a time is in DST or not, it is possible to keep the result of OS::LocalTimezone around and select between the two based on whether the time is DST or not. In local microbenchmarks (calling Date.prototype.toString() in a loop), I observed a 6-10% speedup with this patch. In the browser, the speedup may be even greater as the system call needs to do some extra work to break out of the sandbox. I don't think the microbenchmark is extremely unrealistic; in any real program which calls Date.prototype.toString() multiple times, the cache should hit almost all of the time, as time zone changes are rare. The proximate motivation for this patch was to enable ICU as a backend for timezone information, which is drafted at https://codereview.chromium.org/2724373002/ The ICU implementation of OS::LocalTimezone is even slower than the system call one, but this patch makes their performance indistinguishable on the microbenchmark. In the tz database, many timezones actually do have a number of different historical names. For example, America/Anchorage went through a number of changes, from AST to AHST to YST to AKST. However, both ICU and the Linux OS interfaces just report the modern timezone name in tests for the appropriate timezone name, even for historical times. I can see why this would be: - For ICU, CLDR only has two short names in the data file: the one for dst and non-dst - For Linux, the timezone names do seem to make it into the /etc/localtime file. However, glibc assumes there are only two relevant names and selects between them, as you can see in its implementation of localtime_r: http://bazaar.launchpad.net/~vcs-imports/glibc/master/view/head:/time/tzset.c#L573 So, this cache should be valid until we switch to a more accurate source of short timezone names. BUG=v8:6031 Review-Url: https://codereview.chromium.org/2726253002 Cr-Commit-Position: refs/heads/master@{#43730} Committed: https://chromium.googlesource.com/v8/v8/+/7e87f446258700aaa04d8760271effba9805e89b

Patch Set 1 #

Patch Set 2 : Actually use the cache... #

Total comments: 3

Patch Set 3 : Rebase #

Unified diffs Side-by-side diffs Delta from patch set Stats (+12 lines, -1 line) Patch
M src/date.h View 1 2 2 chunks +10 lines, -1 line 0 comments Download
M src/date.cc View 1 2 1 chunk +2 lines, -0 lines 0 comments Download

Messages

Total messages: 31 (18 generated)
Dan Ehrenberg
3 years, 9 months ago (2017-03-02 21:20:32 UTC) #9
jgruber
https://codereview.chromium.org/2726253002/diff/20001/src/date.h File src/date.h (right): https://codereview.chromium.org/2726253002/diff/20001/src/date.h#newcode97 src/date.h:97: const char** name = is_dst ? &dst_tz_name_ : &tz_name_; ...
3 years, 9 months ago (2017-03-03 08:09:57 UTC) #11
Dan Ehrenberg
https://codereview.chromium.org/2726253002/diff/20001/src/date.h File src/date.h (right): https://codereview.chromium.org/2726253002/diff/20001/src/date.h#newcode97 src/date.h:97: const char** name = is_dst ? &dst_tz_name_ : &tz_name_; ...
3 years, 9 months ago (2017-03-03 12:57:45 UTC) #12
jgruber
https://codereview.chromium.org/2726253002/diff/20001/src/date.h File src/date.h (right): https://codereview.chromium.org/2726253002/diff/20001/src/date.h#newcode97 src/date.h:97: const char** name = is_dst ? &dst_tz_name_ : &tz_name_; ...
3 years, 9 months ago (2017-03-03 13:02:34 UTC) #13
jungshik at Google
As mentioned in another CL, I'm really tempted to move away from the current output ...
3 years, 9 months ago (2017-03-09 23:33:53 UTC) #16
Dan Ehrenberg
On 2017/03/09 23:33:53, jungshik at Google wrote: > As mentioned in another CL, I'm really ...
3 years, 9 months ago (2017-03-10 13:08:58 UTC) #17
ulan
LGTM, but please wait for jgruber@.
3 years, 9 months ago (2017-03-10 17:46:29 UTC) #19
jungshik at Google
On 2017/03/10 13:08:58, Dan Ehrenberg wrote: > On 2017/03/09 23:33:53, jungshik at Google wrote: > ...
3 years, 9 months ago (2017-03-10 20:34:35 UTC) #20
jgruber
lgtm
3 years, 9 months ago (2017-03-11 08:48:47 UTC) #21
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2726253002/20001
3 years, 9 months ago (2017-03-11 08:50:26 UTC) #23
commit-bot: I haz the power
Try jobs failed on following builders: v8_android_arm_compile_rel on master.tryserver.v8 (JOB_FAILED, http://build.chromium.org/p/tryserver.v8/builders/v8_android_arm_compile_rel/builds/33903) v8_linux64_asan_rel_ng on master.tryserver.v8 (JOB_FAILED, ...
3 years, 9 months ago (2017-03-11 08:51:57 UTC) #25
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2726253002/40001
3 years, 9 months ago (2017-03-11 21:10:31 UTC) #28
commit-bot: I haz the power
3 years, 9 months ago (2017-03-11 22:49:44 UTC) #31
Message was sent while issue was closed.
Committed patchset #3 (id:40001) as
https://chromium.googlesource.com/v8/v8/+/7e87f446258700aaa04d8760271effba980...

Powered by Google App Engine
This is Rietveld 408576698