Skip to content
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

Improve validators through a trait index on model #412

Merged
merged 2 commits into from
May 4, 2020
Merged

Conversation

mtdowling
Copy link
Member

This commit is a fairly large update to validators because there's a new
super useful feature on Model where you can now get a Set of shapes that
have a specific trait (and the value is cached). This means that a large
majority of validators that utilized Trait.flatMapStream can now be much
more efficiently written by iterating over the shapes that actually have
the trait directly. Lots of validators were updated to take advantage of
this and be more efficient (particularly HTTP validators and trait
conflict validators).

I also noticed that the TraitValueValidator was validating the prelude
model, and that was pretty expensive. I updated this validator to only
validate the prelude when a specific metadata property is set. Then, in
unit tests, I added a test that ensures that the validator validates the
prelude so that we can be sure that changes made to the prelude are
valid. Because of this change and the trait indexing, JMH shows that the
time to load and validate a model was nearly cut in half
(from about 2ms to 1ms on my old laptop).

I noticed that the UnstableFeatureValidator was still being used on
document shapes even though the spec was updated to remove the
disclaimer that document shapes are unstable, so I removed this
validator.

Issue #, if available:

Description of changes:

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@mtdowling mtdowling requested a review from kstich May 2, 2020 22:10
@mtdowling mtdowling requested a review from kstich May 4, 2020 18:10
mtdowling added 2 commits May 4, 2020 11:38
This commit is a fairly large update to validators because there's a new
super useful feature on Model where you can now get a Set of shapes that
have a specific trait (and the value is cached). This means that a large
majority of validators that utilized Trait.flatMapStream can now be much
more efficiently written by iterating over the shapes that actually have
the trait directly. Lots of validators were updated to take advantage of
this and be more efficient (particularly HTTP validators and trait
conflict validators).

I also noticed that the TraitValueValidator was validating the prelude
model, and that was pretty expensive. I updated this validator to only
validate the prelude when a specific metadata property is set. Then, in
unit tests, I added a test that ensures that the validator validates the
prelude so that we can be sure that changes made to the prelude are
valid. Because of this change and the trait indexing, JMH shows that the
time to load and validate a model was nearly cut in half
(from about 2ms to 1ms on my old laptop).

I noticed that the UnstableFeatureValidator was still being used on
document shapes even though the spec was updated to remove the
disclaimer that document shapes are unstable, so I removed this
validator.
This commit rewrites a lot of NodeValidationVisitors to now emit events
from validation plugins and then allow the visitor to associate the
right context, shape, and severity. This allows the events emitted to
the visitor to contain a more specific source location than N/A.
@mtdowling mtdowling merged commit 20d1045 into 1.0 May 4, 2020
@mtdowling mtdowling deleted the add-trait-cache branch May 4, 2020 20:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants