-
Notifications
You must be signed in to change notification settings - Fork 11.8k
Closed
Description
Laravel Version
10.37.3
PHP Version
8.3.0
Database Driver & Version
No response
Description
As reported on previous Laravel versions, the laravel Validator is very very slow with large datasets:
- Validating large arrays are too slow ideas#2212
- [7.x] Performance improvements #32532
- https://stackoverflow.com/questions/71939857/laravel-validation-large-json-too-slow
- https://stackoverflow.com/questions/67316079/laravel-validation-timesout-for-huge-data
- https://laracasts.com/discuss/channels/requests/request-rules-validation-is-very-slow
I have tried to understand and review the validation process, but it is too complex to be able to send a PR. I could only find that it iterates thousands of times over all values when calculating the validation rules. The problem seems to come only when using asterisks in the fields to validate.
Here a tweet with some tests: https://twitter.com/lito_ordes/status/1735082009666494594
And the repo to test: https://github.com/eusonlito/laravel-validator-slow
Steps To Reproduce
- git clone https://github.com/eusonlito/laravel-validator-slow.git
- cd laravel-validator-slow
- composer install
- php artisan app:slow
Tests Results
"Read Data Time: 0.0120"
"Items: 11351"
"validatorAsterisk Time: 61.9842"
"validatorFixed Prepare: 0.0048"
"validatorFixed Time: 0.1179"
"validatorChunks1000 Time: 2.1746"
"validatorChunks5000 Time: 10.9196"
"validatorChunks10000 Time: 46.9144"
Added memory usage and chunks
"Read Data: 0.0120 seconds / 32.00 memory"
"Items: 11351"
"validatorAsterisk: 60.9496 seconds / 68.50 memory"
"rulesFixed: 0.0049 seconds / 60.50 memory"
"validatorFixed: 0.1193 seconds / 74.00 memory"
"validatorChunks100: 0.3551 seconds / 64.00 memory"
"validatorChunks1000: 2.1089 seconds / 66.00 memory"
"validatorChunks5000: 10.5173 seconds / 70.00 memory"
"validatorChunks10000: 46.5916 seconds / 77.50 memory"
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels