polyfill-library icon indicating copy to clipboard operation
polyfill-library copied to clipboard

Date.toLocaleString slowdown since 3.52.2

Open msvab opened this issue 3 years ago • 5 comments

What

We've noticed that Date.toLocaleString() has great performance degradation on IE11 since version 3.53.2. 3.53.1 is the most recent version which works fine.

Details

Attached is a very basic HTML page which shows the problem. Using version 3.53.1 the benchmark takes 157ms, but on 3.53.2 it takes 6400ms. We use this function to render dates on a datepicker and users with less powerful computers see the "page is not responding due to a long-running script" error.

test.zip

I'm happy to provide more details or if you can point me to the right direction to narrow this issue further?

msvab avatar May 24 '21 14:05 msvab

@msvab Could you maybe create a repo with the contents of that zip? Not really best practice to download and open unknown zips :D

romainmenke avatar May 24 '21 16:05 romainmenke

confirmed :

code : https://github.com/romainmenke/intl-performance-issue-1 hosted : https://romainmenke.github.io/intl-performance-issue-1/

This code was run a 100 times in the reproduction

for (var i = 0; i < 100; i++) {
	var event = new Date(Date.UTC(2012, 11, 20, 3, 0, 0));
	event.toLocaleString('es', { timeZone: 'UTC' });
}
Screenshot 2021-05-24 at 18 44 20

@longlho Can you take a look?

romainmenke avatar May 24 '21 16:05 romainmenke

hmm what about latest version? Those are super old versions that don't use @formatjs/intl-datetimeformat so I don't have much control over it

longlho avatar May 26 '21 02:05 longlho

hmm what about latest version? Those are super old versions that don't use @formatjs/intl-datetimeformat so I don't have much control over it

@longlho The latest version 3.104.0 is actually the one where we discovered the slowdown. Then we went back to identify which was the last version with acceptable speed.

msvab avatar May 26 '21 08:05 msvab

https://github.com/Financial-Times/polyfill-library/compare/v3.53.2..v3.53.1

~~Maybe it's not a change in an Intl polyfill, but something in a dependency, or the build output?~~

To me this is starting to look like 3.53.2 fixed the build process which caused all needed polyfills to be loaded. 3.53.1 is most likely faster because it is not really working.


polyfill list from 3.53.1

 * Features requested: Intl.DateTimeFormat,Intl.DateTimeFormat.~locale.es,Intl.NumberFormat.~locale.es,Intl.PluralRules.~locale.es
 * 
 * - Intl, License: MIT (required by "Intl.PluralRules.~locale.es", "Intl.PluralRules")
 * - Intl.PluralRules, License: MIT (required by "Intl.PluralRules.~locale.es")
 * - Intl.PluralRules.~locale.es, License: MIT */

polyfill list from 3.53.2

 * Features requested: Intl.DateTimeFormat,Intl.DateTimeFormat.~locale.es,Intl.NumberFormat.~locale.es,Intl.PluralRules.~locale.es
 * 
 * - _ESAbstract.Call, License: CC0 (required by "Intl.NumberFormat.~locale.es", "Intl.NumberFormat", "Object.setPrototypeOf", "Object.getOwnPropertyDescriptor", "_ESAbstract.ToPropertyKey", "_ESAbstract.ToPrimitive", "_ESAbstract.OrdinaryToPrimitive")
 * - _ESAbstract.CreateDataProperty, License: CC0 (required by "Intl.PluralRules.~locale.es", "Intl.Locale", "Set", "_ESAbstract.CreateIterResultObject")
 * - _ESAbstract.CreateMethodProperty, License: CC0 (required by "Intl.NumberFormat.~locale.es", "Intl.NumberFormat", "Object.setPrototypeOf", "Object.getOwnPropertyNames", "Array.prototype.includes")
 * - _ESAbstract.Get, License: CC0 (required by "Intl.NumberFormat.~locale.es", "Intl.NumberFormat", "Object.setPrototypeOf", "Object.getOwnPropertyDescriptor", "_ESAbstract.ToPropertyKey", "_ESAbstract.ToPrimitive", "_ESAbstract.OrdinaryToPrimitive")
 * - _ESAbstract.HasOwnProperty, License: CC0 (required by "Intl.NumberFormat.~locale.es", "Intl.NumberFormat", "Object.setPrototypeOf", "Object.getOwnPropertyDescriptor")
 * - _ESAbstract.IsArray, License: CC0 (required by "Intl.NumberFormat.~locale.es", "Intl.NumberFormat", "WeakMap")
 * - _ESAbstract.IsCallable, License: CC0 (required by "Intl.NumberFormat.~locale.es", "Intl.NumberFormat", "Object.setPrototypeOf", "Object.getOwnPropertyDescriptor", "_ESAbstract.ToPropertyKey", "_ESAbstract.ToPrimitive", "_ESAbstract.OrdinaryToPrimitive")
 * - _ESAbstract.SameValueNonNumber, License: CC0 (required by "Intl.NumberFormat.~locale.es", "Intl.NumberFormat", "WeakMap", "_ESAbstract.SameValue")
 * - _ESAbstract.ToBoolean, License: CC0 (required by "Intl.PluralRules.~locale.es", "Intl.Locale", "Set", "_ESAbstract.IteratorComplete")
 * - _ESAbstract.ToObject, License: CC0 (required by "Intl.NumberFormat.~locale.es", "Intl.NumberFormat", "WeakMap", "_ESAbstract.GetIterator", "_ESAbstract.GetV")
 * - _ESAbstract.GetV, License: CC0 (required by "Intl.NumberFormat.~locale.es", "Intl.NumberFormat", "WeakMap", "_ESAbstract.GetIterator")
 * - _ESAbstract.GetMethod, License: CC0 (required by "Intl.NumberFormat.~locale.es", "Intl.NumberFormat", "Object.setPrototypeOf", "Object.getOwnPropertyDescriptor", "_ESAbstract.ToPropertyKey", "_ESAbstract.ToPrimitive")
 * - _ESAbstract.Type, License: CC0 (required by "Intl.NumberFormat.~locale.es", "Intl.NumberFormat", "Object.setPrototypeOf", "Object.getOwnPropertyDescriptor", "_ESAbstract.ToPropertyKey", "_ESAbstract.ToPrimitive", "_ESAbstract.OrdinaryToPrimitive")
 * - _ESAbstract.CreateIterResultObject, License: CC0 (required by "Intl.PluralRules.~locale.es", "Intl.Locale", "Set")
 * - _ESAbstract.GetPrototypeFromConstructor, License: CC0 (required by "Intl.NumberFormat.~locale.es", "Intl.NumberFormat", "WeakMap", "_ESAbstract.OrdinaryCreateFromConstructor")
 * - _ESAbstract.OrdinaryCreateFromConstructor, License: CC0 (required by "Intl.NumberFormat.~locale.es", "Intl.NumberFormat", "WeakMap")
 * - _ESAbstract.IteratorClose, License: CC0 (required by "Intl.NumberFormat.~locale.es", "Intl.NumberFormat", "WeakMap")
 * - _ESAbstract.IteratorComplete, License: CC0 (required by "Intl.NumberFormat.~locale.es", "Intl.NumberFormat", "WeakMap", "_ESAbstract.IteratorStep")
 * - _ESAbstract.IteratorNext, License: CC0 (required by "Intl.NumberFormat.~locale.es", "Intl.NumberFormat", "WeakMap", "_ESAbstract.IteratorStep")
 * - _ESAbstract.IteratorStep, License: CC0 (required by "Intl.NumberFormat.~locale.es", "Intl.NumberFormat", "WeakMap")
 * - _ESAbstract.IteratorValue, License: CC0 (required by "Intl.NumberFormat.~locale.es", "Intl.NumberFormat", "WeakMap")
 * - _ESAbstract.OrdinaryToPrimitive, License: CC0 (required by "Intl.NumberFormat.~locale.es", "Intl.NumberFormat", "Object.setPrototypeOf", "Object.getOwnPropertyDescriptor", "_ESAbstract.ToPropertyKey", "_ESAbstract.ToPrimitive")
 * - _ESAbstract.SameValue, License: CC0 (required by "Intl.NumberFormat.~locale.es", "Intl.NumberFormat", "WeakMap")
 * - _ESAbstract.SameValueZero, License: CC0 (required by "Intl.NumberFormat.~locale.es", "Intl.NumberFormat", "Object.setPrototypeOf", "Object.getOwnPropertyNames", "Array.prototype.includes")
 * - _ESAbstract.ToInteger, License: CC0 (required by "Intl.NumberFormat.~locale.es", "Intl.NumberFormat", "Object.setPrototypeOf", "Object.getOwnPropertyNames", "Array.prototype.includes", "_ESAbstract.ToLength")
 * - _ESAbstract.ToLength, License: CC0 (required by "Intl.NumberFormat.~locale.es", "Intl.NumberFormat", "Object.setPrototypeOf", "Object.getOwnPropertyNames", "Array.prototype.includes")
 * - _ESAbstract.ToPrimitive, License: CC0 (required by "Intl.NumberFormat.~locale.es", "Intl.NumberFormat", "Object.setPrototypeOf", "Object.getOwnPropertyNames", "Array.prototype.includes", "_ESAbstract.ToString")
 * - _ESAbstract.ToString, License: CC0 (required by "Intl.NumberFormat.~locale.es", "Intl.NumberFormat", "Object.setPrototypeOf", "Object.getOwnPropertyNames", "Array.prototype.includes")
 * - _ESAbstract.ToPropertyKey, License: CC0 (required by "Intl.NumberFormat.~locale.es", "Intl.NumberFormat", "Object.setPrototypeOf", "Object.getOwnPropertyDescriptor")
 * - Array.prototype.includes, License: MIT (required by "Intl.NumberFormat.~locale.es", "Intl.NumberFormat", "Object.setPrototypeOf", "Object.getOwnPropertyNames")
 * - Array.prototype.sort, License: MIT (required by "Intl.PluralRules.~locale.es", "Intl.Locale")
 * - Object.getOwnPropertyDescriptor, License: CC0 (required by "Intl.NumberFormat.~locale.es", "Intl.NumberFormat", "WeakMap", "Symbol")
 * - Object.keys, License: MIT (required by "Intl.NumberFormat.~locale.es", "Intl.NumberFormat", "WeakMap", "Symbol")
 * - Object.assign, License: CC0 (required by "Intl.NumberFormat.~locale.es", "Intl.NumberFormat", "Intl.PluralRules")
 * - Intl.getCanonicalLocales, License: MIT (required by "Intl.NumberFormat.~locale.es", "Intl.NumberFormat", "Intl.PluralRules")
 * - Object.getOwnPropertyNames, License: CC0 (required by "Intl.NumberFormat.~locale.es", "Intl.NumberFormat", "WeakMap", "Symbol")
 * - Object.setPrototypeOf, License: MIT (required by "Intl.NumberFormat.~locale.es", "Intl.NumberFormat", "Intl.PluralRules")
 * - Symbol, License: MIT (required by "Intl.NumberFormat.~locale.es", "Intl.NumberFormat", "WeakMap", "Symbol.toStringTag")
 * - Symbol.iterator, License: MIT (required by "Intl.NumberFormat.~locale.es", "Intl.NumberFormat", "WeakMap", "_ESAbstract.GetIterator")
 * - _ESAbstract.GetIterator, License: CC0 (required by "Intl.NumberFormat.~locale.es", "Intl.NumberFormat", "WeakMap")
 * - Symbol.species, License: MIT (required by "Intl.PluralRules.~locale.es", "Intl.Locale", "Set")
 * - Set, License: CC0 (required by "Intl.PluralRules.~locale.es", "Intl.Locale")
 * - Symbol.toStringTag, License: MIT (required by "Intl.NumberFormat.~locale.es", "Intl.NumberFormat", "WeakMap")
 * - WeakMap, License: MIT (required by "Intl.NumberFormat.~locale.es", "Intl.NumberFormat", "Intl.PluralRules")
 * - Intl.Locale, License: MIT (required by "Intl.NumberFormat.~locale.es", "Intl.NumberFormat", "Intl.PluralRules")
 * - Intl.PluralRules, License: MIT (required by "Intl.NumberFormat.~locale.es", "Intl.NumberFormat")
 * - Intl.NumberFormat, License: MIT (required by "Intl.NumberFormat.~locale.es")
 * - Intl.DateTimeFormat, License: MIT (required by "Intl.DateTimeFormat.~locale.es")
 * - Intl.DateTimeFormat.~locale.es, License: MIT
 * - Intl.NumberFormat.~locale.es, License: MIT
 * - Intl.PluralRules.~locale.es, License: MIT */

romainmenke avatar May 26 '21 08:05 romainmenke