question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`Map` polyfill (`get(key)`) is very slow

See original GitHub issue

We recently starting using polyfill-library@3.34.0 to polyfill ES6 for (only) IE11 in Tableau. This caused a severe performance regression in our rendering code, which was traced to the Map polyfill. Removing Map and Set from our config resolved the issue – luckily our code only currently needs the native partial support for Map in IE11. (I don’t know if removing Set was also necessary, but since IE11 has partial support for both, I decided to err on the side of removing both.)

Unfortunately I have not investigated deeply enough to suggest a fix, but our profiling session indicated CreateMethodProperty(Map.prototype...) (23.1.3.6 Map.prototype.get (key)) was the culprit.

Here is our config, for reference:

const ie11_es6_opts = {
  uaString: 'Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko',
  minify: false,
  excludes: [
    'Map',
    'Set',
  ],
  features: {
    'es6': { flags: ['gated'] }
  }
};

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:11 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
JakeChampioncommented, Aug 14, 2019

@zloirock Good point! I missed that part when reading the spec, thanks for pointing it out.

@neenhouse, feel free to implement a more optimised implementation 😃

0reactions
JakeChampioncommented, May 10, 2020

@craigkovatch Yes please, if you could link it to this issue that would be great

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why is JavaScript map() polyfill so slow
The property with the key '2' is no longer defined. For Arrays that means there is an empty slot. The specification also allows...
Read more >
How do the ES6 Map shims work - Stack Overflow
There are two ways that come to mind. First, obviously, you can have an array of keys, and search it linearly: Map1 =...
Read more >
Why is JavaScript map() polyfill so slow – Valuable Tech Notes
According to a JSPerf snippet (and some others), default JavaScript map() implementation is 21% slower than using a basic for . enter image...
Read more >
Array.prototype.flatMap() - JavaScript - MDN Web Docs
The flatMap() method returns a new array formed by applying a given callback function to each element of the array, and then flattening...
Read more >
Maps and Sets, goodbye polyfill ?! - ES Discuss
What do engines do when they face an object-as-map (random and potentially numerous keys)? Do they try to find a shape/hidden class and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found