dry-validation: Schema definition is too slow

First of all, thank you so much for making dry-validation. At @Shopify, we are looking forward to try it on our scale.

This is not particularly dry-validation issue, but for some reason the gem require time is quite slow:

require 'bundler/setup'
require 'benchmark'

puts Benchmark.measure {
  require 'dry-validation'
}
$ ruby bench.rb
0.240000   0.150000   0.390000 (  0.401198)

That’s 400ms or almost half a second just to require the gem. All credits to @casperisfine for discovering this problem.

@solnic @timriley

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 15 (6 by maintainers)

Most upvoted comments

There we go:

Schema defined in 0.075425
Form defined in 5.43349
Form (with type specs) defined in 0.077061
------------------------------------------------------------------------------
Warming up --------------------------------------
              Schema     1.000  i/100ms
                Form     1.000  i/100ms
Form with type specs     1.000  i/100ms
Calculating -------------------------------------
              Schema     15.248  (±13.1%) i/s -     75.000  in   5.045985s
                Form      0.174  (± 0.0%) i/s -      1.000  in   5.749034s
Form with type specs     14.810  (±20.3%) i/s -     71.000  in   5.000067s

Comparison:
              Schema:       15.2 i/s
Form with type specs:       14.8 i/s - same-ish: difference falls within error
                Form:        0.2 i/s - 87.66x slower

This means there will be no practical difference between schema with or without coercions (via type specs) 😃 This is in a branch, I gotta clean some things up and merge it to master. I’ll close this issue once that’s done.

Thank you for the new release! I’ve checked it with our huge schema and results are pretty good. It takes around 7ms for the schema definition 🚀 🚀 🚀