-
-
Notifications
You must be signed in to change notification settings - Fork 433
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
Incremental Compile Performance Regression 8.0.3 -> 8.0.11 #1215
Comments
Could you identify specifically which version of ts-loader the regression occurred in please? |
I grabbed the webpack build times and recorded them below, the clock time on cold builds is actually higher than what webpack reports. 8.0.3 - cold build: 34845ms incremental: 14388ms Note: Sample size of 1 build per version, but there's an obvious step function between 8.0.6 and 8.0.7, both for cold and incremental builds #1202 seems to be the culprit. Incremental builds are effectively the same cost as cold builds, which is pretty much a dealbreaker for upgrading atm. I'd love to help diagnose however possible. By comparison, executing |
Thanks for the detail @berickson1! Interestingly, @sheetalkamat's #1202 was designed to improve performance - and I believe (looking at the details) was tested with a fairly big project @sheetalkamat has access to. So it's intriguing that this would have precisely the opposite effect on your builds. I appreciate you can't share your build, but is there a way you could come up with a reliable repro repo? That will make it easier for others to help |
I spent some time fiddling and built an (arguably ugly) repro. Currently the example is using ts-loader 8.0.7. https://github.com/berickson1/project-references-demo/tree/ts-loader-1215 To Test:
Downgrade to 8.0.6 and notice that incremental build times drop substantially. One interesting tidbit is that the inclusion of an @material-ui/core had a noticeable impact on both cold and incremental builds (even when code relating to imported types was not touched) |
Thanks @berickson1! It's funny you should mention material UI as I half remember something about that being used by TypeScript as an explicit test case against compilation time regressions. @sheetalkamat / @andrewbranch do you have any thoughts about this? |
#1217 should fix this |
I just pulled the latest Below is the latest build-time test dumps: Note: Not sure why my incremental build times are so much worse than cold atm - perhaps something else part of the build, but either way I tested this starting at the latest version, working backwards - cold build -> record times -> change specific file for incremental build -> record fimes |
The repro you created had the issue that was fixed in #1217 |
The repro I shared above was the closest I could build to what we have in our closed source repo in a reasonable amount of time.
Incremental: (Same change I made in all the above tests)
|
Hey @berickson1, Without a reliable reproduction repo, it won't be easy to help you I'm afraid (as @sheetalkamat suggests) I appreciate it's a closed source repo and that does not make your life easier. I have definitely been there! But without that, it's going to be hard for progress to be made. |
I've spent some time digging into this using I'm seeing a ton of files from node_modules pass through this function, none of which will ever resolve since they're not included in any of my tsconfig.json's for compilation. It appears that having 50+ projects totaling >2k files makes this 2x Map iteration + 1x Array iteration is non-trivially expensive when there's enough files being sourced from node_modules. Adding a conditional to skip all |
Thanks for sharing your findings. The node_modules piece is interesting. Out of curiosity, how does your codebase align with @DanielRosenwasser's perf code advice here: https://github.com/microsoft/TypeScript/wiki/Performance?utm_source=typescript-weekly.com&utm_campaign=typescript_weekly_159&utm_medium=email (does it follow advised good practices etc) |
Generally, we match up quite well. Things we are doing: Things we're not doing: |
This is very strange... I'm curious as to what the cause of this might be. What sort of things are you seeing included that you are surprised by; and and you see what the thing is that triggers that? And I'm guessing tsc doesn't include these? |
They're all .d.ts files from imported libraries (or @types).
and
tsconfig has: |
As an addition the above - I hope to have some more time next week to dig a little deeper on why this code path is being hit. If all goes well, I hope to be able to contribute a fix back. |
Awesome - all help gratefully received ❤️🌻 |
One quick fix: Enabling the I'm in the process of getting contributions back to ts-loader ok'd by my employer, I hope to have a path forward to share a couple other code-changes by mid next-week. |
I’m not super familiar with the issue here, but since Sheetal is out for the holidays I wanted to chime in really quick before you get too far down this path to point out that there is a pretty large set of scenarios when you have project files in node_modules, and that’s via lerna or yarn workspaces monorepos, which symlink projects through each other’s node_modules. I’m not sure how common it is to have a monorepo like that run through Webpack, but it’s something to think about. I also noticed that function calls |
Thanks for chiming in @andrewbranch - always appreciated ❤️🎄 |
That's a fair point re: node_modules. ts-loader has a |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Closing as stale. Please reopen if you'd like to work on this further. |
Note: This is in a relatively large repo that uses project references + composite projets
~55 typescript composite packages (and slowly growing)
Webpack + ts-loader for compilation (running in watch mode)
Expected Behaviour
Incremental compile is a similar duration after upgrade of ts-loader (~11 seconds)
Actual Behaviour
Incremental compile is 20x longer (~240 seconds)
Steps to Reproduce the Problem
Unfortunately I'm not able to share the repo - but a simple drop-in replacement of ts-loader caused a huge spike in incremental compile times. I'd love to provide any relevant debugging output to help diagnose this.
I think I can work around it by using fork-ts-checker-webpack-plugin, but ideally the root cause in ts-loader could be identified and fixed.
The text was updated successfully, but these errors were encountered: