-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
[Build Performance] Including yup
adds 3 seconds to lib type-checking
#46856
Comments
I'm not quite sure how to turn this into something actionable. The types are just legitimately extremely complex. Here's a snippet from export interface RequiredDateSchema<TType extends Maybe<Date>, TContext extends AnyObject = AnyObject> extends DateSchema<TType, TContext, NonNullable<TType>> {
// Cheap half
defined(msg?: MixedLocale['defined']): DefinedDateSchema<TType, TContext>;
required(msg?: MixedLocale['required']): RequiredDateSchema<TType, TContext>;
optional(): DateSchema<TType, TContext>;
notRequired(): DateSchema<TType, TContext>;
// Expensive half
default<D extends Maybe<TType>>(def: Thunk<D>): If<D, RequiredDateSchema<TType | undefined, TContext>, RequiredDateSchema<Defined<TType>, TContext>>;
nullable(isNullable?: true): RequiredDateSchema<TType | null, TContext>;
nullable(isNullable: false): RequiredDateSchema<Exclude<TType, null>, TContext>;
} Commenting out the "expensive half" saves about 0.4s (!!), but it's easy to see why -- validating that all of these instantiations are legal is a huge amount of work. We might be able to make this a little faster, but we're not going to be able to check this fast enough that it won't have a measurable impact on your overall build perf. Even a 10x improvement from 3s to 0.3s is still going to add up to a lot over multiple builds. It's not possible for us to reuse validation results between builds because each project in a composite build might have different settings or pull in different types (in fact, the latter is almost certainly the case in most builds), both of which can affect whether or not an arbitrary lib typechecks successfully or not. If you're pulling in lib files someone else published to npm, |
I've personally seen a handful of type breaks of downstream types as package upgrades land, so had left this disabled for safety. We also have some complex recursive types in our repo - so improvement here could potentially have downstream benefits to others, but it's hard to directly enumerate. I'm starting to do some performance profiling of our project to identify and improve hotspots. |
Ideas that @amcasey and I had after spitballing on this for a while:
|
I think either of those would help our scenario - our setup basically templated tsconfig files (see below) so there shouldn't be any additional types included. Of the above, I do like the idea of grouped cohorts - that way it's still very explicit that behaviour is tied together (perhaps a simple checker could be put in place to validate that there's consistency in tsconfig.json files in the same cohort)
|
FWIW, in 4.6 we're doing a lot better on |
I can confirm that setting |
Bug Report
In our (private) typescript project that utilizes composite projects, we've been struggling with increasing compile times as more projects have been added. I took a stab at investigating this based on the Performance Tracing Docs. Ultimately I found that consuming
yup
adds ~3s to each package build (on an M1 MBP). Given we have 100+ composite projects in the repo (not all of which are impacted, since not all importyup
), this starts to stack up as a non-trivial increase to build times.This can be mitigated by setting
skipLibCheck
totrue
, but ideally this would be false for complete validation of downstream types.🔎 Search Terms
performance yup lib type checking
🕗 Version & Regression Information
⏯ Playground Link
Playground link with relevant code
The above playground link isn't overly useful given this is a performance bug, I've also prepared a minimal repro. https://github.com/berickson1/Playground/tree/master/type-checking-perf
💻 Code
🙁 Actual behavior
Project compile time went from sub-second to over 3s on an M1 MBP to a single project. When using composite projects, this has a larger impact for every package that includes
yup
.Trace ZIP:
trace.json.zip
🙂 Expected behavior
Project compile sees a trivial increase when including
yup
. This could either be managed by 1) improving peformance of type-checking or 2) leveraging a shared in-memory cache for node_module lib types across composite buildsThe text was updated successfully, but these errors were encountered: