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

Optimize library model lookups #265

Merged
merged 4 commits into from Dec 5, 2018
Merged

Optimize library model lookups #265

merged 4 commits into from Dec 5, 2018

Conversation

msridhar
Copy link
Collaborator

@msridhar msridhar commented Dec 4, 2018

NullAway was spending a lot of time checking if we had library models for methods. This PR optimizes the process in two ways:

  1. First check if we have a model for a method with the same name before checking the full method signature.
  2. In 1, compare Name objects, as converting a Name to a String is actually costly.

@@ -208,7 +208,7 @@ private NullnessStore lambdaInitialStore(
NullnessStore environmentMapping =
Objects.requireNonNull(
environmentNullness.getEnvironmentMapping(underlyingAST.getLambdaTree()),
"no environment stored for lambda " + underlyingAST.getLambdaTree());
"no environment stored for lambda");
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

separate, tiny optimization: I saw the string conversion of the lambda tree showing up in profiles

@msridhar msridhar changed the base branch from ms/string-utils-model to master December 4, 2018 22:02
@msridhar msridhar changed the title [WIP] optimize library model lookups Optimize library model lookups Dec 5, 2018
@msridhar
Copy link
Collaborator Author

msridhar commented Dec 5, 2018

@lazaroclapp this is ready for review

@msridhar msridhar merged commit ee0f8f3 into master Dec 5, 2018
@kageiit kageiit deleted the ms/test-optimizations branch December 5, 2018 04:09
Copy link
Collaborator

@lazaroclapp lazaroclapp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this is merged already, but I just went through it. Looks pretty cool to me.

private static Symbol.MethodSymbol lookupHandlingOverrides(
Symbol.MethodSymbol symbol, Types types, NameIndexedMap<Boolean> optLookup) {
if (optLookup.nameNotPresent(symbol)) {
// no model matching the method name, so we don't need to check for overridden methods
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice optimization 👍

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.

None yet

3 participants