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
Conversion of large array to a Set seems slow #1253
Comments
We have fast paths for iterating arrays that bypass the (slow)
|
thanks, that's interesting. I'm happy for you to close this as I assume using those fast paths for Sets/Maps will be done at some point (understandably not a priority I assume). But equally can be left open too! |
Lets keep it open until we add the fast paths |
@tmikov hi, does this PR fixes this? |
@efstathiosntonas it is one of several. We are working on multiple improvements that have sped it up by more than 10x. |
Bug Description
A discussion came up in my company about the performance benefits of
set.has
overarray.includes
(eslint rule). I was interested if these performance benefits translated over to Hermes from v8 or whatever JS engine was used to benchmark those two methods.Quick disclaimer - absolutely not a performance expert or anything. So I may have got this very wrong, and if so, I apologise and please close this issue.
I wrote a quick script to do both these operations on three differently sized large arrays/sets. I then ran the script on node.js (v18) and Hermes, compiled from source. Firstly, here's the script:
The basics of the code is from here and modified by myself: https://stackoverflow.com/a/65240169
I ran both of these from the command line; the results are here:
hermes (
build_release/bin/hermes test.js
)node (
node test.js
):as you can see set.has is very quick on both (not sure how it can be 0? but I think the code is correct). But on Hermes, the conversion to a set (i.e
new Set(array)
) is much slower than on node (approaching 10x in some cases).Is this conclusion correct? have I done anything wrong?
Hermes git revision (if applicable):
005897de9 (HEAD -> main, origin/main, origin/HEAD) Run API tests against the sandbox runtime (#1248) 17 hours ago
OS: macOS 14
RN version: N/A
Platform (most likely one of arm64-v8a, armeabi-v7a, x86, x86_64): arm64 (M1 macbook Pro)
Steps To Reproduce
The Expected Behavior
For
new Set
to have comparable performance in Hermes to Node.The text was updated successfully, but these errors were encountered: