-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
[V8] Array.prototype.splice ~100x slower in V3 with symbol polyfill #677
Comments
|
@zloirock Thanks for the response. I see this behavior in Chrome 77 and Node 12.13.0. The issue seemed to be less significant in Firefox/Safari but the regression is still very much noticeable. |
I found the problem place. It's calling of this test. We try to use It's V8 bug, not a A solution for you - avoid cc @littledan |
If I understood V8 source correctly, it's |
Recent V8 versions also have a --trace-protector-invalidation flag that might help demonstrate what's going on:
I would still like to understand why core-js must touch these prototypes / species symbols. Above you said 'removing this polyfill will be a breaking change.' Could you explain (perhaps off-thread since this is slightly off-topic) what the polyfill does and why it must be applied even in recent V8 versions that should already implement the latest version of the spec? Perhaps we can figure out a way to implement these polyfills without hitting all of V8's slow paths. |
@schuay it's a polyfill for feature, which causes this deoptimization (in this case - |
Digging the V8 code, since |
Anything that avoids changing built-in prototypes (like |
Yes that certainly helps. We only care about E.g. for
|
@mathiasbynens in this case, we do not change built-in prototypes, we change
|
@schuay but since |
The point is not to make these changes only when needed, i.e. not during feature detection. |
@schuay we don't do it on feature detection. |
|
@schuay I know, I wrote it above, I already wrote a workaround. |
Sounds great 👍
I'm not sure what you mean by generics, but RegExp methods do support subclassing. E.g. And e.g. |
@schuay not all |
Feel free to ping me via email or on the tracker. |
Seems I closed it too early. |
Sure, we can just detect the engine version and do not call feature detection in modern V8: if (V8_VERSION >= 51) return true; but it is a very bad practice and used only in the absence of any alternatives. |
Right, it only works if IsArray returns true, so for Arrays or Proxies on Arrays. This works, although I don't know if you can assume the existence of Proxies:
|
@schuay thanks, it's an interesting solution and it could work. However, 2 problems:
What do you think? |
Not sure I understand the second point, are you asking if the Proxy-based solution could somehow cause a global switch to flip to the slow path in other engines? If so, anything is possible I guess.. But I think it's very unlikely given that no global state is modified in the proxy-based solution. |
@schuay yep, something like that. Let's think about alternative solutions for tomorrow - maybe we could find something better - and if not let's apply one of the mentioned above. |
I added engine version detection and not calling this feature detection in modern V8. If feature detection or usage of |
Thanks, benchmark results confirm that this worked! |
Thanks! Are you planning to do something similar for other builtins, especially Edit: Just saw #679. |
I experienced the same issue with Is it a known issue or has anyone else experienced the same? |
@slowcheetah could you provide some idea of what's going on with this issue? I'm confused about whether or not this is fixed. |
It's definitely not this error. Without any additional information, I can't say anything. |
I filed a V8 bug on this as I was recently bit by this, in a different project, as well https://bugs.chromium.org/p/v8/issues/detail?id=13202 |
This seems like it may be similar to #377. We recently discovered a perf issue after upgrading to v3.2.1 from v2 and tracked it down to a call to
Array.prototype.splice
that was occurring within a loop. Testing the performance of that method in isolation in environments withcore-js/features/symbol
applied revealed a similar issue.I created a sample benchmark/repro that shows the relative performance with different versions.
The text was updated successfully, but these errors were encountered: