Anatoliy Balakirev (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=5c62d60...
) *created* an issue
Hibernate Validator (
https://hibernate.atlassian.net/browse/HV?atlOrigin=eyJpIjoiYzJmM2FiMWUyZ...
) / Bug (
https://hibernate.atlassian.net/browse/HV-1933?atlOrigin=eyJpIjoiYzJmM2Fi...
) HV-1933 (
https://hibernate.atlassian.net/browse/HV-1933?atlOrigin=eyJpIjoiYzJmM2Fi...
) Performance issue for validating list with 20k elements (
https://hibernate.atlassian.net/browse/HV-1933?atlOrigin=eyJpIjoiYzJmM2Fi...
)
Issue Type: Bug Affects Versions: 8.0.0.Final Assignee: Unassigned Components:
performance, validators Created: 10/Jan/2023 06:29 AM Priority: Major Reporter: Anatoliy
Balakirev (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=5c62d60...
)
We have a PUT REST endpoint, which accepts an autogenerated object, which is in fact a
list of objects. We send a request there, which contains around 23k of elements. Elements
in that list have a couple of concrete implementations, each has a couple of required
fields and a list with a couple more elements of the same type. When hibernate validator
is enabled on that endpoint - it takes somewhere between 30 and 50 seconds to validate
everything. When I replace that validation with manually written methods - it takes around
0.5 seconds to validate the same. The sample project to reproduce this is here:
https://github.com/anatoliy-balakirev/hibernate_validator_performance_issue (
https://github.com/anatoliy-balakirev/hibernate_validator_performance_issue )
If you are on Linux, just run the following command in the root of the project (make sure
your JAVA_HOME points to Java 17):
./mvnw clean test
Or this on Windows:
./mvnw.cmd clean test
And you’ll see these logs:
2023-01-10T15:17:32.316+01:00 INFO 18248 --- [ main]
com.example.demo.DemoControllerTest : Sending
'/endpoint_with_explicit_validation' request...
2023-01-10T15:17:32.643+01:00 INFO 18248 --- [o-auto-1-exec-1]
com.example.demo.DemoFilter : Got into filter
2023-01-10T15:17:33.419+01:00 INFO 18248 --- [o-auto-1-exec-1]
com.example.demo.DemoController : Got into the controller with explicit
validation, amount of elements in the request: 23489
2023-01-10T15:17:33.503+01:00 INFO 18248 --- [ main]
com.example.demo.DemoControllerTest : It took 1187ms to execute the
'/endpoint_with_explicit_validation' request
2023-01-10T15:17:33.572+01:00 INFO 18248 --- [ main]
com.example.demo.DemoControllerTest : Sending '/endpoint_with_validation'
request...
2023-01-10T15:17:33.607+01:00 INFO 18248 --- [o-auto-1-exec-2]
com.example.demo.DemoFilter : Got into filter
2023-01-10T15:18:09.510+01:00 INFO 18248 --- [o-auto-1-exec-2]
com.example.demo.DemoController : Got into the controller with validation, amount
of elements in the request: 23489
2023-01-10T15:18:09.512+01:00 INFO 18248 --- [ main]
com.example.demo.DemoControllerTest : It took 35940ms to execute the
'/endpoint_with_validation' request
2023-01-10T15:18:09.534+01:00 INFO 18248 --- [ main]
com.example.demo.DemoControllerTest : Sending '/endpoint_without_validation'
request...
2023-01-10T15:18:09.584+01:00 INFO 18248 --- [o-auto-1-exec-3]
com.example.demo.DemoFilter : Got into filter
2023-01-10T15:18:09.637+01:00 INFO 18248 --- [o-auto-1-exec-3]
com.example.demo.DemoController : Got into the controller without validation,
amount of elements in the request: 23489
2023-01-10T15:18:09.638+01:00 INFO 18248 --- [ main]
com.example.demo.DemoControllerTest : It took 104ms to execute the
'/endpoint_without_validation' request
Which are basically about running three tests:
* endpoint_with_explicit_validation - validation is done with manually written method
* endpoint_with_validation - validation is done using Hibernate Validator
* endpoint_without_validation - no validation at all
If you want to see what exactly is being validated - uncomment this line:
https://github.com/anatoliy-balakirev/hibernate_validator_performance_iss...
(
https://github.com/anatoliy-balakirev/hibernate_validator_performance_iss...
)
I’m using the latest Spring Boot version (3.0.1), Java 17.0.5 (Amazon Corretto) and Maven
3.8.6
P.S. I’m not sure if this should be a Bug or rather an Improvement, so left the default
one there.
(
https://hibernate.atlassian.net/browse/HV-1933#add-comment?atlOrigin=eyJp...
) Add Comment (
https://hibernate.atlassian.net/browse/HV-1933#add-comment?atlOrigin=eyJp...
)
Get Jira notifications on your phone! Download the Jira Cloud app for Android (
https://play.google.com/store/apps/details?id=com.atlassian.android.jira....
) or iOS (
https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=Em...
) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100213- sha1:cca7326 )