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

DCOS-51596: Services Table: avoid rerenders #3792

Closed
wants to merge 2 commits into from

Conversation

DanielMSchmidt
Copy link
Contributor

@DanielMSchmidt DanielMSchmidt commented Apr 8, 2019

Testing

  • Open a services page with react dev tools and flash on rerender enabled and see that there are less then before this change
  • Check that loading icons and deploying status bars still display as before

Trade-offs

Dependencies

Screenshots

Before After first commit After - no render if no data change
Bildschirmfoto 2019-04-08 um 16 07 45 Bildschirmfoto 2019-04-08 um 16 48 55 Screen Shot 2019-04-09 at 2 16 10 PM

@nLight nLight requested a review from mperrotti April 8, 2019 16:33
@natmegs
Copy link
Contributor

natmegs commented Apr 8, 2019

The status column conversion is in its own commit since it was more complex than the others and affected multiple files. Comparison of react updates:

@natmegs
Copy link
Contributor

natmegs commented Apr 9, 2019

Just finished a nasty rebase since the accurate service status stuff merged and touched a lot of the same files. Would be great if someone familiar with that work could give this a look over cc @TattdCodeMonkey @pierrebeitz @Poltergeist

@natmegs natmegs marked this pull request as ready for review April 9, 2019 19:44
brandonc
brandonc previously approved these changes Apr 9, 2019
Copy link
Contributor

@brandonc brandonc left a comment

Choose a reason for hiding this comment

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

Brilliant and obviously a lot of work. 🎉 I saw about 1/3 or 1/2 as many updates as master branch

@brandonc brandonc force-pushed the danielmschmidt/DCOS-51377 branch 2 times, most recently from c545c25 to a9dca61 Compare April 9, 2019 20:53
@brandonc
Copy link
Contributor

brandonc commented Apr 9, 2019

I rebased in order to fix a commit message lint error.

brandonc
brandonc previously approved these changes Apr 9, 2019
@brandonc
Copy link
Contributor

brandonc commented Apr 9, 2019

Fixing test failure Natalie fixing test failures

@DanielMSchmidt
Copy link
Contributor Author

Conflicts again and I run into strange bugs when I try to fix them (spent like 1,5h with it). I would say, let's get #3796 merged first and ship the status column individually.

@DanielMSchmidt DanielMSchmidt changed the title DCOS-51377: Services Table: avoid rerenders DCOS-51596: Services Table: avoid rerenders Apr 10, 2019
@DanielMSchmidt
Copy link
Contributor Author

I created a new issue to track the efforts for the status column: DCOS-51596

@juliangieseke juliangieseke added this to the 1.13 milestone Apr 10, 2019
@nLight nLight removed this from the 1.13 milestone Apr 10, 2019
@GeorgiSTodorov
Copy link
Contributor

When running with fixtures enabled, the services table is loading forever.

Copy link
Contributor

@pierrebeitz pierrebeitz left a comment

Choose a reason for hiding this comment

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

i think there are some gains in comprehensibility and this maintainability here that we should aim for.

also the services table does not load for me (for FE-cluster, SOAK and fixtures).

id: string | number;
displayDeclinedOffers: boolean;
appsWithWarnings: number | null;
unableToLaunch: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

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

these props look like they could benefit from telling apart a couple of things.
i'd propose to start with services and groups (a.k.a serviceTree here). there seems to be uncertainty (| null) by not telling them apart. also it looks like isServiceTree and isService is the same information because it's either one or another. that seems to cry for a union type.

);
}

//Master
Copy link
Contributor

Choose a reason for hiding this comment

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

there are multiple comments still in here.

instancesCount: service.getInstancesCount(),
runningInstances: service.getRunningInstancesCount()
};
let serviceTreeProps = {};
Copy link
Contributor

Choose a reason for hiding this comment

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

can we move that into a block where we already know that service is a ServiceTree and make it a const? this would get rid of having to ask service instanceof ServiceTree multiple times here.

statusText,
totalCount,
priorityStatusCount,
tooltipContent
Copy link
Contributor

Choose a reason for hiding this comment

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

i wonder if the code would tell a clearer story if we moved those props right into RenderServiceTree (currently line 2).

timeQueued: number | null;
appsWithWarnings: number | null;
displayDeclinedOffers: boolean;
unableToLaunch: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

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

could we make it so that the statusIcon did not need to know about some of these things?
conceptually it feels like it should not need to know about whether it's associated to a service or a group/serviceTree for example.

since?: unknown;
}

interface ItemWithQueue {
Copy link
Contributor

Choose a reason for hiding this comment

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

that's neat!

since: string | null;
}

const isUnableToLaunch = (service: Service | Pod | ServiceTree) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

couldn't we use ItemWithQueue here instead of Service | Pod | ServiceTree?

}

const isUnableToLaunch = (service: Service | Pod | ServiceTree) => {
const queue = service.getQueue() as ServiceQueue | null;
Copy link
Contributor

@pierrebeitz pierrebeitz Apr 11, 2019

Choose a reason for hiding this comment

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

we wouldn't need the typecast here then 😊


const isUnableToLaunch = (service: Service | Pod | ServiceTree) => {
const queue = service.getQueue() as ServiceQueue | null;
const UNABLE_TO_LAUNCH_TIMEOUT = 1000 * 60 * 30;
Copy link
Contributor

Choose a reason for hiding this comment

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

we're recreating this constant every time we call isUnableToLaunch. let's pull this to the root-level of the file!

const unableToLaunch = isUnableToLaunch(service);
const appsWithWarnings = isServiceTree
? (service as ServiceTree)
.filterItems((item: any) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

our typings say that this is a Service. why override it with any?

possibly the types of ServiceTree.filterItems are wrong? (i updated them and possibly forgot that a serviceTree can also contain another ServiceTree. if so, please let's fix the types instead of working around here.

@pierrebeitz pierrebeitz deleted the danielmschmidt/DCOS-51377 branch August 30, 2019 06:58
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.

8 participants