You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using large, deeply nested schemas with lots of sync tests and only one async test, calling schema.validate() converts ALL tests to promises. This means that a schema with 100 sync validation tests (or nested tests) and one async validation test will use 101 promises to validate the schema.
I first noticed this issue when validating an array of 5,000 items with a rather large nested schema but only one async validation that was actually a noop. The validation would take up to 10 seconds. But when removing that validation and calling validateSync the time dropped to roughly 2 seconds.
The included PR updates the createValidation function in a manner that only pushes validations onto the event loop if they are a promise, otherwise it validates as a sync function. This avoids scheduling sync work in the event loop and leads to some major performance improvements.
The text was updated successfully, but these errors were encountered:
When using large, deeply nested schemas with lots of sync tests and only one async test, calling
schema.validate()
converts ALL tests to promises. This means that a schema with 100 sync validation tests (or nested tests) and one async validation test will use 101 promises to validate the schema.I first noticed this issue when validating an array of 5,000 items with a rather large nested schema but only one async validation that was actually a noop. The validation would take up to 10 seconds. But when removing that validation and calling
validateSync
the time dropped to roughly 2 seconds.The included PR updates the
createValidation
function in a manner that only pushes validations onto the event loop if they are a promise, otherwise it validates as a sync function. This avoids scheduling sync work in the event loop and leads to some major performance improvements.The text was updated successfully, but these errors were encountered: