A certain combination of schema validations, rules and data lead to performance problems.
E.g.:
rule(:users).each do
# ...
end
The culprit seems to be Dry::Schema::Result#message_set
.
That is, it seems that building the MessageSet
is expensive.
In combination with a big data set to validate, this method is called very often via Dry::Validation::Rule#each
, hence leading to mentioned performance problems.
Is there an easy way to memoize the result of Dry::Schema::Result#message_set
for the case where options = EMPTY_HASH
is passed as argument? If yes, this might be enough to solve this problem.