-
-
Notifications
You must be signed in to change notification settings - Fork 119
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
Explore xxh algo and benchmark #588
base: master
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. |
Size Change: 0 B Total Size: 3.84 kB ℹ️ View Unchanged
|
I'm exploring the disassembly of It does seem to help all engines:
I've also established in emotion-js/emotion#3241 (comment) that the final string formatting function can have a big impact, so goober doing a simple I need to explore more before giving a better answer but I'll include the updated goober version in my benchmarks, though the collision rate makes it a bad candidate for emotion. I'll try to figure if I can find a better algo for your requirements (super low byte size). |
Note that you don't return anything from the goober hash functions in your tests, that might also impact the result (engines could ellicit an unused constant value with no side-effect). Also your benchmark has a single constant string as dataset instead of a proper parameter, that's another factor that could be used for optimization by the engines. It would be better to build a representative datasets of strings you see in production, and run the perf tests on that dataset. |
Hello. I slightly modified the code to make xxh32 suitable for benchmarking, and obtained the following results:
Actually, considering the bundle size of goober, using xxh32 is overkill. I just wrote this because there was talk about my library. :) |
This is related and in response of emotion-js/emotion#3241
cc @romgrk
The weird part -- but kinda expected -- was that on node
18.17.0
goober is constantly second but then drops with newer versions.Besides that it really is peculiar what is happening on
bun
that runs so slow?!Anyway, I've copy/pasted the xxh on goober's hash perf test, and these are the results:
and
Looking forward to your thoughts