Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overloaded constructor of Date is slow #589

Open
zzemla opened this issue Jun 21, 2023 · 1 comment
Open

Overloaded constructor of Date is slow #589

zzemla opened this issue Jun 21, 2023 · 1 comment

Comments

@zzemla
Copy link

zzemla commented Jun 21, 2023

With the overloaded Date constructor, creating new Date objects takes at least an order of magnitude longer on Firefox, blocking the main JS thread and causing performance issues on sites that process large number of dates.

This is largely due to the new URL(...) constructor being called multiple times to extract origin of each script on the stack during the new Date call, to check if Date hasTaintedMethod. The URL constructor is much slower than the Date constructor (about ~ 9x times slower).

I'm not sure why such check for tainted methods on Date object is important, but I would suggest to at least check if taintedOrigins is not-empty before doing

const stackOrigins = getStackTraceOrigins(getStack())
to improve performance.

@jonathanKingston
Copy link
Contributor

Thanks for the report, we've disabled this in Firefox for now before we look into the fix. Thanks for the detailed investigation here!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants