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

Memoize data derived from useExtensions #4232

Conversation

vojtechszocs
Copy link
Contributor

With #4211 the result value of useExtensions hook changes only when necessary, i.e. when the relevant RootState.FLAGS subset is changed. (For now, the runtime list of extensions is assumed to be immutable, so the only extension-related "change vector" is Console feature flag Redux substate.)

This PR applies memoization to data derived from useExtensions calls to further avoid unnecessary React component re-renders.

@openshift-ci-robot openshift-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. component/core Related to console core functionality approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Feb 6, 2020
/>
),
})),
[resourcePageExtensions, props.kind, props.kindObj, props.name, props.namespace, props.match],
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note, we could also replace props.xxx with just props but that isn't 100% correct from hook dependency point of view (since we only use specific parts of the whole props object in the computation function).

The main reason for not destructuring props into smaller pieces is to minimize changes.

.filter(
(tab) =>
props.obj?.data &&
referenceForModel(tab.properties.model) === referenceFor(props.obj.data),
Copy link
Member

Choose a reason for hiding this comment

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

IMO, it would be much safer to compute referenceFor(props.obj.data) first and not depend on the object

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed, will do.

@atiratree
Copy link
Member

few notes:

  • we should consolidate ResourceTabPage and HorizontalNavTab extensions as there is an overlap
  • ExtensionRegistry.getResourceTabPages is not used

@vojtechszocs
Copy link
Contributor Author

  • we should consolidate ResourceTabPage and HorizontalNavTab extensions as there is an overlap

Agreed, let's do this as a follow-up.

  • ExtensionRegistry.getResourceTabPages is not used

Thanks, removed 😃

@openshift-ci-robot openshift-ci-robot added the component/sdk Related to console-plugin-sdk label Mar 13, 2020
@vojtechszocs
Copy link
Contributor Author

/retest

Copy link
Member

@atiratree atiratree left a comment

Choose a reason for hiding this comment

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

what about this version?

frontend/public/components/utils/horizontal-nav.tsx Outdated Show resolved Hide resolved
frontend/public/components/utils/horizontal-nav.tsx Outdated Show resolved Hide resolved
frontend/public/components/utils/horizontal-nav.tsx Outdated Show resolved Hide resolved
@vojtechszocs
Copy link
Contributor Author

@suomiy Looks good, will make those changes.

@atiratree
Copy link
Member

  • we should consolidate ResourceTabPage and HorizontalNavTab extensions as there is an overlap

Agreed, let's do this as a follow-up.

ok!

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Mar 16, 2020
@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: suomiy, vojtechszocs

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

1 similar comment
@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-ci-robot
Copy link
Contributor

openshift-ci-robot commented Mar 16, 2020

@vojtechszocs: The following test failed, say /retest to rerun all failed tests:

Test name Commit Details Rerun command
ci/prow/verify 4981231 link /test verify

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-merge-robot openshift-merge-robot merged commit 0bd24e2 into openshift:master Mar 16, 2020
@spadgett spadgett added this to the v4.5 milestone Mar 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. component/core Related to console core functionality component/sdk Related to console-plugin-sdk lgtm Indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants