GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||
GeezerVison is showing github.com — Performance: improve `objectWithoutPropertiesLoose` on V8 by romgrk · Pull Request #16357 · babel/babel Conversation
Contributor
I've been doing some benchmarks and I've seen
I'm not familiar with your codebase, I have tentatively used
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
|
There was an error while loading. Please reload this page.
|
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/56543 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Please change |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thanks, I've updated the PR. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
On macOS Safari the initial is faster than updated:
https://jsbench.me/1hltu3eit5/1 I migrated the benchmark to jsbench.me because the other one pops up click baits. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
sadly those benchmarks are not valid, as v8 is going to optimize some of this code if we are looking at performance
try running it without the extra loop there seem to not be measurable time difference between both pieces of code |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Weid, JSC is usually happy with
Do you have a link to any relevant discussion?
What do you mean by without the loop? Do you have a better benchmark you could share to shed light on the measurements you see? Wrt to the benchmark I have, I added a loop to ensure the function is optimized asap. This helper is what The other aspect that I didn't like is the |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I've built a small benchmark to test on each engine, I can replicate the results you see with JSC. Despite the slowdown on JSC, I'd still argue that this implementation is better as the gains for V8 are more drastic, and more V8 users also means we should give more weight to that segment. Note that with this new implementation, V8 and JSC perform roughly the same, whereas the old one was considerably slower on V8 than on JSC. But if you have more details on those upcoming V8 changes, please do share, I'd be happy to learn more. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thanks! helpers.objectWithoutPropertiesLoose = helper("7.0.0-beta.0")` export default function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; for (var key in source) { if ({}.hasOwnProperty.call(source, key)) { if (excluded.indexOf(key) < 0) target[key] = source[key]; } } return target; } `; |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I have integrated one change from the snippet above, moving For more details on the |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Some corrections, I've inspected JSC's output further and I think I was wrong when I said it didn't do escape analysis. I've added colors to the disassembly and I think it is able to optimize the I also previously wrote that chrome's market share is 65%, but including edge in the mix means V8 has a 70% usage currently, so I'd still recommend merging this one. You have all the information, but if you don't feel like merging the PR feel free to close it. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your detailed explanation!
In fact, we currently have terser enabled for most complex helpers, which compresses Object.prototype.hasOwnProperty into {}.hasOwnProperty. I'm surprised this affects performance.
https://jsbench.me/8jluk7693l/1
I did a simple test and it seems it doesn't affect performance in v8.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Yeah it's possible that V8 is able to perform ellision on that value through escape analysis. It's also possible that it's not, and the |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I don't like market-share-based arguments (if we optimize for V8, then it gives even more advantage to V8 leading to it having a higher market share). However, given that the performance improvement here is higher than the perf regression in SM/JSC, I'm fine with this PR. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
objectWithoutPropertiesLoose on V8
|
I don't love having the ecosystem that much in the hands of google either, but JSC is already vastly more performant than V8 anyway, and is still more performant than V8 for this particular case even with the change. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.