hibernate-validator
hibernate-validator copied to clipboard
HV-1831 Optimize cascading validation for large lists
https://hibernate.atlassian.net/browse/HV-1831
this is only a version of https://github.com/hibernate/hibernate-validator/pull/1157 for a main branch with javax->jakarta moved so far.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license. For more information on licensing, please check here.
Quality Gate failed
Failed conditions
6.6% Duplication on New Code (required ≤ 3%)
C Reliability Rating on New Code (required ≥ A)
See analysis details on SonarCloud
Catch issues before they fail your Quality Gate with our IDE extension
SonarLint
Thanks for your pull request!
This pull request appears to follow the contribution rules.
› This message was automatically generated.
I had a look at the numbers but I'm not sure to what I should compare them to? Could you clarify?
I think I understand them: could you check if in the case with a cycle, we are not consistently slower? I would have expected things to be mostly transparent?
Also both versions tested include your previous optimization, right?
Also both versions tested include your previous optimization, right?
yes, all the runs are on top of main, so the previous improvements are already included.
I had a look at the numbers but I'm not sure to what I should compare them to? Could you clarify?
I haven't initially compared to results from main, just predefined/default, as my thought was that the change is really about disabling the tracking ... here are the result from running the benchmark on main:
Benchmark Mode Cnt Score Error Units
CascadedWithLotsOfItemsValidation.testCascadedValidationWithLotsOfItems thrpt 20 15547.480 ± 187.809 ops/s
PredefinedScopeCascadedWithLotsOfItemsValidation.testPredefinedScopeCascadedValidationWithLotsOfItems thrpt 20 16213.816 ± 180.518 ops/s
so with that compared to the case when we disable tracking:
Benchmark Mode Cnt Score Error Units
CascadedWithLotsOfItemsValidation.testCascadedValidationWithLotsOfItems thrpt 20 16303.592 ± 205.026 ops/s
PredefinedScopeCascadedWithLotsOfItemsValidation.testPredefinedScopeCascadedValidationWithLotsOfItems thrpt 20 24974.083 ± 276.476 ops/s
default case matches the results from main (no tracking improvements), and the predefined is much better as we disable tracking entirely there.
let me also run the one with cycles on main too...
Here are the results for the case with cycles:
main:
Benchmark Mode Cnt Score Error Units
CascadedWithLotsOfItemsAndCyclesValidation.testCascadedValidationWithLotsOfItems thrpt 20 10976.153 ± 139.115 ops/s
PredefinedScopeCascadedWithLotsOfItemsAndCyclesValidation.testCascadedValidationWithLotsOfItems thrpt 20 10829.914 ± 130.121 ops/s
this patch:
Benchmark Mode Cnt Score Error Units
CascadedWithLotsOfItemsAndCyclesValidation.testCascadedValidationWithLotsOfItems thrpt 20 10850.865 ± 103.808 ops/s
PredefinedScopeCascadedWithLotsOfItemsAndCyclesValidation.testCascadedValidationWithLotsOfItems thrpt 20 10835.561 ± 100.276 ops/s
It's slower than CascadedWithLotsOfItemsValidation, but I guess the reason is that we have to try to cascade into the object that creates a cycle, and that means at minimum getting the value, which involves reflection and so on.
Congrats @marko-bekhta ! This is awesome work!
thanks @gsmet 🥳🙂! I'll try to get a few more things merged and maybe do an alpha 9.1 some time next week 🤞🏻 🙂