Closed Bug 1952623 Opened 1 year ago Closed 1 year ago

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)

task

Tracking

()

RESOLVED FIXED
139 Branch
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)

This is a very artificial testcase and Temporal is probbaly not on perf critical path. Feel free to WONTFIX :)

Component: JavaScript Engine → JavaScript: Internationalization API
Summary: Generating current date using Temporal.Now.plainDateISO is 11x slower than generating random date using Temporal.PlainDate.from (year, month, day) is 10x slower than calling → Generating current date using Temporal.Now.plainDateISO is 11x slower than generating random date using Temporal.PlainDate.from (year, month, day)

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?

Flags: needinfo?(andrebargull)

(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.

Flags: needinfo?(andrebargull)
Blocks: sm-js-perf
Severity: -- → N/A
Priority: -- → P3

Directly get the system time zone offset to avoid creating additional time
zone objects.

Assignee: nobody → andrebargull
Status: NEW → ASSIGNED

Address the TODO note about combining GetISOPartsFromEpoch and BalanceISODateTime.

See Also: → 1943230

Drive-by change:

  • SystemUTCEpochNanoseconds is infallible, so we can return the result
    directly and don't need an out-param.
Pushed by andre.bargull@gmail.com: https://hg.mozilla.org/integration/autoland/rev/5c1a710f1cd8 Part 1: Get system time zone offset from DateTimeInfo. r=spidermonkey-reviewers,mgaudet https://hg.mozilla.org/integration/autoland/rev/e113ac96f039 Part 2: Combine GetISOPartsFromEpoch and BalanceISODateTime. r=spidermonkey-reviewers,mgaudet https://hg.mozilla.org/integration/autoland/rev/225df4261b1c Part 3: Avoid unnecessary to nanoseconds conversion. r=mgaudet
Status: ASSIGNED → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 139 Branch

N=5000000
PlainISODate: https://share.firefox.dev/4jgRCsc (600ms)
Random: https://share.firefox.dev/4czHAAe (1.1s)

So we are now 18x faster!

i am guessing that this should go to release at the same time as Temporal?

Yes, this will land in the same release as bug 1912511.

See Also: → 1961480
QA Whiteboard: [qa-triage-done-c140/b139]
Blocks: 1980560
See Also: 1943230
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: