-
Notifications
You must be signed in to change notification settings - Fork 203
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
Performance degradation in v2 compared to 1.2.2 #79
Comments
Hi @svtokarevsv. Thanks for checking this. I was aware there would be a performance impact due to added support for unicode characters. Unicode in itself wouldn't cause the perf impact, but we'd need another refactor to convert all the strings into arrays internally. Right now we're iterating the strings (hash, salt, alphabet, seps) multiple times with each encode and decode. I didn't think performance would be an issue, that's why I went with the current implementation. I don't have the time to do this now, but I'm open to PRs. |
This performance issue blew my production servers up, this is significant. Downgrading to 1.2.2 seems to fix it |
Actually because I'm OCD as hell, I've upgraded back to it, and put some caching in place to minimize the amount of times it gets called |
Sorry about that @jpike88! If anybody is up for the refactor, I'm happy to accept PRs. Just can't invest much time at the moment personally (getting married next week! 😄), but feel free to use 1.2.2 if your perf is impacted. |
In addition, during fuzz testing, I've discovered a memory leak of sorts with v2 that would literally BLOW UP the entire server, unfortunately... would be great to see this fixed. For now I'm reverting to v1.2.2. |
@JaneJeon that's intriguing! 🤔 We don't keep any references stashed away, so I honestly have no idea about the source of the memory leak you mentioned. Could you share the source of your testing repo? |
@niieani I don't have the exact code for the moment (mainly because it was involving a plugin that used hashids) BUT through debugger I was able to narrow down the "freeze" down to the following:
I was using version 2.0.1, and the random strings were generated by faker.js. So, in effect, I was doing fuzz testing when step 2 broke. I only had to call the decode function <30 times for it to blow up, it usually happened around step 15-25. |
Even if you decide not to fix this issue, I still think we should add a fuzz testing of sorts to make sure it works with arbitrary strings. |
That's a very good idea! I have limited time for OSS lately, but I'm very much open to contributions from anyone who'd like to tackle this. |
Great to hear that @JaneJeon. Before 2.1.0 there was a bad condition check in a Anyway, I've bit the bullet and spent a few hours tuning performance (#206). Results look really positive!
|
🎉 This issue has been resolved in version 2.2.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Old package performance
![image](https://user-images.githubusercontent.com/16964561/64199812-259d7c80-ce59-11e9-85b8-76272a62eef5.png)
![image](https://user-images.githubusercontent.com/16964561/64199949-7a40f780-ce59-11e9-9e25-92bfaf1f5c2a.png)
v2 version performance
The new version is 5 times less performant.
Not sure if you're worried of performance on that scale, just wanted to let you know.
I'll be still using old version because of this reason.
Thanks
The text was updated successfully, but these errors were encountered: