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

test: Investigate removing IsEmptyInterface #1

Closed
wants to merge 2 commits into from

Conversation

eps1lon
Copy link
Owner

@eps1lon eps1lon commented Jan 15, 2020

Removes IsEmptyInterface. There are slight reductions in the number of Nodes, Identifiers, Symbols and Types but yarn perf:IsEmptyInterface does not yield a significant improvement:

  • 4.52478006190000000000 seconds per run seconds per run on master compared to
  • 4.27613066370000000000 seconds per run on this branch
  • resulting in 0.2486493982 reduction or 6%.

Maybe we need to improve other areas first to see a significant improvement (e.g. BaseCSSProperties). Maybe we need a larger codebase to check.

/cc @amcasey

Copy link

@amcasey amcasey left a comment

Choose a reason for hiding this comment

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

What scenario are you measuring?

Emit time: 0.00s
Total time: 4.12s
Total time: 5.37s
Copy link

Choose a reason for hiding this comment

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

Did it get slower? That's odd.

Copy link
Owner Author

Choose a reason for hiding this comment

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

It's just a single run. When averaging 10 runs it did get slightly faster (6%). The snapshot is more for the other diagnostics (see snapshots/README.md)

* {} is a top type so e.g. `string extends {}` but not `string extends object`
* 3. false if the given type is `unknown`
*/
export type IsEmptyInterface<T> = And<
Copy link

Choose a reason for hiding this comment

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

I was expecting CoerceEmptyInterface and maybe IsAny, And, and Or to go as well. Are they used for other things?

Copy link
Owner Author

Choose a reason for hiding this comment

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

We can remove CoerceEmptyInterface. The others are used to check if we can call useStyles with one or zero arguments.

I'll cherry-pick mui/material-ui#19243 and mui/material-ui#19259 first and see if we get a more significant improvement.

Copy link

Choose a reason for hiding this comment

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

Did the other commits help?

Copy link
Owner Author

Choose a reason for hiding this comment

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

Hard to tell since these were only affecting withStyles and styled. We did get some slight runtime improvements in our test_types job but these are only single runs. Might not have been significant.

Having a large codebase where I can just run tsc on would help. The original repo in microsoft/TypeScript#34801 didn't help much because it includes a full webpack build (and therefore noise).

My guess is that types related to CSSProperties are the issue. These are quite complicated so I didn't look into them much. Will be todays and probably tomorrows agenda since today is a bit busier than usual.

Copy link

Choose a reason for hiding this comment

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

There were some repro notes in microsoft/TypeScript#34801. Would they get you more useful numbers?

Copy link
Owner Author

Choose a reason for hiding this comment

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

All I see is "takes forever to report errors in vscode". Without know their vscode environment or how long "forever" is I can't do much. Sorry but I can't find detailed instructions.

Copy link

Choose a reason for hiding this comment

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

I'm sure I could reconstruct a repro, but I think this is a bit of a tangent anyway - my local experiments suggest that the CSS properties types are more impactful.

@eps1lon
Copy link
Owner Author

eps1lon commented Jan 15, 2020

What scenario are you measuring?

import { makeStyles } from "@material-ui/styles";

// https://github.com/mui-org/material-ui/issues/19113#issuecomment-573614279

const useStaticStyles = makeStyles({ root: { color: "blue" } });
const useDynamicStyles = makeStyles({
  root: { color: (props: { color: string }) => props.color }
});
function Component() {
  const staticClasses = useStaticStyles(); // No error
  const throwingClasses = useDynamicStyles(); // $ExpectError
  const dynamicClasses = useDynamicStyles({ color: "blue" });
}

-- https://github.com/eps1lon/mui-types-perf/blob/master/sources/IsEmptyInterface.test.ts

@eps1lon eps1lon closed this in #3 Jan 21, 2020
@eps1lon eps1lon deleted the test/always-optional-props branch January 21, 2020 20:13
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.

2 participants