-
Notifications
You must be signed in to change notification settings - Fork 106
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
perf(node): reduce reflect FieldByName and Field calls #829
Conversation
These calls are expensive to be put inside nested for loops. The performance can be improved if the results of these calls are cached.
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple nits, otherwise looks good, thanks!
ytypes/node.go
Outdated
if !ok { | ||
return nil, status.Errorf(codes.NotFound, "element struct type %v does not contain key field %s", listElemT, fieldName) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you place this error statement above, then this error can be changed to say codes.Internal, and that it is expected that this field should always be populated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are good suggestions, thanks. Changes made in the latest commit.
Resolve the comments in openconfig#829
The
reflect
method calls are expensive to be put inside nested for-loops. The performance can be improved if the results of these calls are cached.Here are some rough reference numbers from e2e testing sending 2000 leaf-list updates in a SetRequest: