-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Performance/Memory issues with rdl.Validate when FullValidation enabled #26
Comments
Thanks, good find. Will fix that. Or... you can if you want :-) |
I have a fix which involves exposing a |
Well, Fixing it behind the scenes would be best, it is just a performance optimization for the Go library, other libraries have different ways to deal with it, so don't worry about those just yet. If you want to just send me a sketch (or pointer to your changes) I can integrate it, I just thought you were closer to it, having done the performance comparison already. |
I changed it to use a transparent cache - no change to the exposed API. Take a look at #29 |
Fixed in Release 1.4.13, PR #29 |
The current go implementation of
rdl.Validate
callsNewTypeRegistry(schema)
on every invocation. For a complex schema, this is a costly operation.ardielle-go/rdl/validator.go
Line 46 in 0e40fcc
This becomes apparent in go when unmarshalling large objects with nested structs containing a lot of "derived-from-String" types.
In tests, I've found that code which would just cache the TypeRegistry per schema when calling
schema.Build()
and then use that in ardl.Validate2()
style call which can accept a preconstructed TypeRegistry gives a close to 10x improvement on JSON unmarshalling speed.The text was updated successfully, but these errors were encountered: