Please sign in to comment.
(PUP-5659) Validate all relationships
Before this, only relationships formed with the relationship operations <- -> <~ and ~> were validated. This validation checkes that the referenced resource exists in the catalog and reports an error if not. The identical relationship formed via use of the meta parameters after, require, subscribe, and notify were not validated. This led to that errors in catalogs were not caught until the catalog was applied on the agent. This commit makes use of the recently added catalog validators and adds validatio of all relationships. When making this change the existing code in the relationship validator needed refactoring. It was then detected that it used an array.find and a predicate lambda to see if a variable was one out of 3 possible symbols. That was measured to be 6x slower that the fastest (hash lookup= on Ruby 1.9.3. The relationship checking can be called thousands of times and that statement alone could add several seconds to a catalog compilation. Note that the validation runs after the catalog is finalized. That means that it includes all operations that could have modified the catalog. (Overrides, queries, relationships, defaults, etc.) Also note that this means that relationships formed with the arrow operators are checked twice. This because there is otherwise no information that points to that source location in case of an error. It was measured that a mechanism that would avoid doing it twice was just as costly as doing the check a second time. It may be possible to instead add additioal location information, but that is a greater change, that also uses more memory.
- Loading branch information
Showing with 37 additions and 5 deletions.