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.

__createBinding performance issue on web browsers

See original GitHub issue

__createBinding, which is used in __exportStar, uses accessor descriptors to get exported modules. In our product, we see a 10x performance degradation referencing exported enums this way compared to using a direct access object. We’ve verified that by refactoring our enum exports to be explicitly defined and not *, this issue is not seen.

Likewise, this issue is not seen in v1.14.0 when __createBinding looks like

    __createBinding = function(o, m, k, k2) {
        if (k2 === undefined) k2 = k;
        o[k2] = m[k];
    };

current implementation:

    __createBinding = Object.create ? (function(o, m, k, k2) {
        if (k2 === undefined) k2 = k;
        Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
    }) : (function(o, m, k, k2) {
        if (k2 === undefined) k2 = k;
        o[k2] = m[k];
    });

JSBench: https://jsbench.me/yokwmk1mau/1

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
jakebaileycommented, Jun 24, 2022

Unfortunately, I don’t think TypeScript is going to be able to provide the info required to prove that we can make that optimization; if you’re doing export * from "./otherFile" in some file, it can’t know which of those bindings are mutable and which aren’t (and that can continue onward as it’s reexported). I think that this is about as fast as we’re going to be able to make it.

0reactions
jramsleycommented, Jun 24, 2022

The issue with that is that if m[k] is later mutated (or is a getter), the mutation won’t propagate when accessing o[k2], like it does in the case of real ES modules.

This is correct, but for our use case the * import is for classes and enums which aren’t being mutated.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshoot Chrome Browser performance issues
Is Chrome running too slow or using too much memory? Here's how to troubleshoot Chrome Browser performance issues on Microsoft ® Windows ®...
Read more >
How to Speed Up Chrome, Firefox & Other Browsers - Avast
Resetting your browser should improve its performance. Try a different browser. If none of the above solutions has fixed the problem — you've ......
Read more >
View Binding - Android Developers
Use Jetpack Compose on Wear OS · Compose performance · Navigation · Buttons · Cards ... Web-based content ... Known issues · StackOverflow....
Read more >
Slow performance, unexpected responses and ... - Solve CRM
Slow performance, unexpected responses and troubleshooting browser related issues. · Firefox open History > Clear recent history > choose “Time range to clear: ......
Read more >
The Ultimate Guide to Fixing JavaScript Performance ...
Similarly, CSS requires 73KB but performance problems are rare unless ... browser tools to help assess your JavaScript performance issues.
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