Open Bug 1744326 Opened 4 years ago Updated 1 year ago

`mozilla::intl::calendar::GetBcp47Type` is slow on YouTube and Facebook

Categories

(Core :: JavaScript: Internationalization API, task, P3)

task

Tracking

()

People

(Reporter: gregtatum, Unassigned)

References

(Blocks 2 open bugs)

Details

I did some profiling for mozilla::intl APIs, and it turns out mozilla::intl::calendar::GetBcp47Type is the slowest mozilla::intl call. This is due primarily to lock contention and reading strings inside of a resource bundle.

Here is an example stack:

pthread_mutex_lock
std::__1::mutex::lock()
umtx_lock_70
(anonymous namespace)::init_resb_result(UResourceDataEntry*, unsigned int, char const*, int, UResourceDataEntry*, char const*, int, UResourceBundle*, UErrorCode*)
ures_getNextResource_70
initFromResourceBundle(UErrorCode&)
ulocimp_toBcpType_70
uloc_toUnicodeLocaleType_70
mozilla::intl::Calendar::GetBcp47Type()
DefaultCalendar(JSContext*, mozilla::UniquePtr<char [], JS::FreePolicy> const&, JS::MutableHandle<JS::Value>)
js::intl_defaultCalendar(JSContext*, unsigned int, JS::Value*)
ResolveLocale
resolveDateTimeFormatInternals
getDateTimeFormatInternals
resolvedOptions
nsThread::ProcessNextEvent(bool, bool*)

YouTube: https://share.firefox.dev/3EmRbbH
STR: Go to youtube.com in Nightly. Click on a video to play it.

Facebook: https://share.firefox.dev/3Eq1tYp
STR: Log into facebook, scroll the home page, and click on a page.

It might be worth optimizing the ICU4C code, or comparing it with an ICU4X implementation.

Priority: -- → P3
You need to log in before you can comment on or make changes to this bug.