-
-
Notifications
You must be signed in to change notification settings - Fork 99
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
Generate validators without dispatching #46
Comments
@Stranger6667 this approach would make the definition of the keywords more involved and dependent on multiple keywords, still it might provide noticeable improvements. Have you considered the possibility of running all the validators in parallel (via rayon)? On a multicore machine it might provide comparable performances. |
Yes, my attempts gave me worse results than a single thread implementation :( But, I believe the problem was that I didn't use any heuristic about when to run validation in parallel and when not. At the moment only
I believe that it can be significant speedup, indeed, but implementing a balanced approach (that will be beneficial for most of the cases) will require more investigation & experiments that I was able to do :) I'll try to organize my thoughts on this matter and will post it here :) |
I tried to compose a validator manually and compare the results with the current approach. Example schema:
Input data: Validator code (which is probably incomplete, misses some checks & optimizations):
Benchmark for a compiled validator: Which is ~x3.58 faster. I think that in general on big input data the benefit will be more significant and even if the validator above is incomplete I think that we can expect a really significant boost |
@Stranger6667 : something that might also be worth to mention is that certain keywords have some intrinsic dependencies on others (ie. |
I wasn't completely sure what do you mean, but having your message as a start I added some more thoughts here - #63 |
I’ll read it carefully in a bit ... but looks very similar to what I eventually had in mind (in order to pay the Value::as_* once and not once per validator) |
Even though compiling validators gives pretty good results, it is not the fastest way to perform validation in all circumstances. If we know the schema during the build time, then we can generate code that will be more efficient, than the current approach.
For example if we have this schema:
then our current approach will basically iterate over a vector of trait objects and call their
validate
/is_valid
methods.The idea is to generate code like this:
https://github.com/horejsek/python-fastjsonschema does this.
The text was updated successfully, but these errors were encountered: