Improve BottomUpIndex performance #2367
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When doing some ad-hoc profiling on the language server using aws service models I noticed that BottomUpIndex was taking up a lot of CPU time. This was because it used selectors and PathFinder to determine the paths from resources/operations up to their enclosing service. Selectors are pretty slow in comparison to regular java code, and when the model is large with many services/operations, this index can take a while to compute. BottomUpIndex is used for validating
@cfnResource
(through CfnResourcePropertyValidator -> CfnResourceIndex), so anyone using this trait is paying this performance cost (in particular, SDK code generators).To get a rough idea of how much faster this commit makes BottomUpIndex, I ran model validation using the cli on all aws service models with and without this change a few times each:
I also added a jmh benchmark for BottomUpIndex (named it KnowledgeIndicies in case we want to add more, but we could keep them separate too and I can change the name). The benchmark results:
Before this change:
After this change:
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.