-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Bad performance #1601
Comments
hi @lpinca , this issue is interesting. I'm new to this, but I'd love to contribute in optimizing this (since we are using it in our project). Is there any particular part that consume most resources compared to others? |
@ronayumik I honestly don't know, I'm not familiar with joi codebase and I didn't profile the code to find bottlenecks. |
I don't see the issue here. You are comparing apples and oranges, and a factor of 3 vs a performance optimized application specific validator seems reasonable. That being said, there are likely opportunities to improve the performance of Joi, especially for specific corner cases. |
Agreed but the factor is 300 not 3. My intention is not to compare joi with ajv. The point is that 31k ops/sec for a dead simple schema like the one in the issue description seem low. I would expect performance to be at least an order of magnitude better. |
Ah, yes I misread, and you point is correct. Though, I still suspect it would require architectural changes to achieve something like that. |
@kanongil I'm not sure I understand your comment but I'm not familiar with |
|
Not that I know, even though I think joi is very rarely the culprit of any service. I understand this kind of discussions, but micro-benchmarks are meaningless when you consider your application as a whole, the point is whether the value provided by the library is what you're looking for or not. If you really need speed, you wouldn't be doing JavaScript. I'll investigate this example whenever I have some time. Already by inlining the options you double the performance, but that's still not enough. |
I agree and that is generally true but frameworks like |
Using a bare server with no business logic in it is a useless comparison. Start adding some actual workload on that and see which share of the performance is taken by joi or even fastify and you'll see things differently. I'm not saying joi can't be faster, just putting things in perspective. |
To avoid repeating something that was eloquently said: https://hueniverse.com/when-500-faster-is-garbage-553121a088c3. That's not to say I don't want to reach the best possible performance, I'll take whatever's actionable, I just won't enter into a competition with other libraries. |
Yes but it depends on the use case. I'm analysing the performance of a web app in production and in some routes the biggest amount of CPU time is spent on validation due to joi which is a shame. This is clearly visible in the flame graph. I really like joi and its API, I wish it was faster, that's all. |
So do I, but we need to find something actionable about it. |
Commit a1a79b3 should help a bit.
It's still not great but already doubles the performance for this specific use case. My time being finite, it'll be an on and off job, so if it's really important for you, help me work on it or go with ajv. |
Thank you @Marsup. |
This last commit kind of closes this issue as a monitoring tool for this case. Feel free to contribute either in terms of new benchmarks or performance improvements. I'll make sure to keep things moving in this area but I can't promise a big break in performances anytime soon. I don't think it's necessary to keep this issue open as it's as endless as can be. |
Awesome. I will see if I can dig up some of my old tests, and add them to the suite. |
This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions. |
Context
What are you trying to achieve or the steps to reproduce ?
Joi.validate()
seems to have some performance issues. Here is a benchmark with a very simple schema.Which result you had ?
What did you expect ?
Better performance. Am I doing something wrong?
Thank you.
The text was updated successfully, but these errors were encountered: