Generating current date using Temporal.Now.plainDateISO is 11x slower than generating random date using Temporal.PlainDate.from (year, month, day)
Categories
(Core :: JavaScript: Internationalization API, task, P3)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox139 | --- | fixed |
People
(Reporter: mayankleoboy1, Assigned: anba)
References
(Blocks 2 open bugs)
Details
Attachments
(5 files)
N=5000000
PlainISODate: https://share.firefox.dev/4bAZUIo (11s)
Random: https://share.firefox.dev/4i7w9S4 (1s)
| Reporter | ||
Comment 1•1 year ago
|
||
| Reporter | ||
Comment 2•1 year ago
•
|
||
This is a very artificial testcase and Temporal is probbaly not on perf critical path. Feel free to WONTFIX :)
| Reporter | ||
Updated•1 year ago
|
Comment 3•1 year ago
|
||
Taking a quick look at the profile, we spend roughly half our time in icu_76::TimeZone::createTimeZone under GetOrCreateIntlTimeZone. We check for a cached intl::TimeZone object on the TimeZoneValue. However, the TimeZoneValue is freshly recreated each iteration by calling SystemTimeZone in SystemDateTime.
If we could cache the system time zone somewhere, I think we could avoid this. We would have to be sure that the cached time zone is still valid. If that's tricky to guarantee, maybe a one-item cache here would be good enough.
Anba, do you have any intuition about whether the performance of this code even matters?
| Assignee | ||
Comment 4•1 year ago
|
||
(In reply to Iain Ireland [:iain] from comment #3)
Anba, do you have any intuition about whether the performance of this code even matters?
Yes, I think it makes sense to ensure that this code doesn't run too slow.
Time zone caches for Temporal aren't yet implemented (bug 1840424), but at least for the system time zone case it should be possible to clone the time zone cached in js::DateTimeInfo.
Updated•1 year ago
|
| Assignee | ||
Comment 5•1 year ago
|
||
Directly get the system time zone offset to avoid creating additional time
zone objects.
Updated•1 year ago
|
| Assignee | ||
Comment 6•1 year ago
|
||
Address the TODO note about combining GetISOPartsFromEpoch and BalanceISODateTime.
| Assignee | ||
Comment 7•1 year ago
|
||
Drive-by change:
SystemUTCEpochNanosecondsis infallible, so we can return the result
directly and don't need an out-param.
https://hg.mozilla.org/mozilla-central/rev/5c1a710f1cd8
https://hg.mozilla.org/mozilla-central/rev/e113ac96f039
https://hg.mozilla.org/mozilla-central/rev/225df4261b1c
| Reporter | ||
Comment 10•1 year ago
•
|
||
N=5000000
PlainISODate: https://share.firefox.dev/4jgRCsc (600ms)
Random: https://share.firefox.dev/4czHAAe (1.1s)
So we are now 18x faster!
| Reporter | ||
Comment 11•1 year ago
|
||
i am guessing that this should go to release at the same time as Temporal?
| Assignee | ||
Comment 12•1 year ago
|
||
Yes, this will land in the same release as bug 1912511.
Updated•1 year ago
|
Description
•