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

perf(node): reduce reflect FieldByName and Field calls #829

Merged
merged 3 commits into from
May 22, 2023

Conversation

jayzhudev
Copy link
Contributor

@jayzhudev jayzhudev commented May 1, 2023

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:

Version Time
Before #829 ~2,300 ms
After #829 ~900 ms

These calls are expensive to be put inside nested for loops.
The performance can be improved if the results of these calls are cached.
@google-cla
Copy link

google-cla bot commented May 1, 2023

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.

@coveralls
Copy link

coveralls commented May 2, 2023

Coverage Status

Coverage: 90.116% (-0.004%) from 90.12% when pulling 3ff1eb8 on jayzhudev:render-perf into cbef8ea on openconfig:master.

Copy link
Collaborator

@wenovus wenovus left a 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 Show resolved Hide resolved
ytypes/node.go Outdated Show resolved Hide resolved
ytypes/node.go Outdated
Comment on lines 438 to 440
if !ok {
return nil, status.Errorf(codes.NotFound, "element struct type %v does not contain key field %s", listElemT, fieldName)
}
Copy link
Collaborator

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.

Copy link
Contributor Author

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.

@wenovus wenovus merged commit 17c4673 into openconfig:master May 22, 2023
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.

3 participants