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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Circular dependency checker can be slow #19794

Closed
1 task done
vbraun opened this issue Jan 14, 2021 · 2 comments
Closed
1 task done

Circular dependency checker can be slow #19794

vbraun opened this issue Jan 14, 2021 · 2 comments

Comments

@vbraun
Copy link

vbraun commented Jan 14, 2021

馃殌 Feature request

Command (mark with an x)

  • serve

Description

For us the majority of an incremental rebuild time is spent in circular dependency checking

On a largeish hybrid app with complicate imports (in particular, the angularjs part doesn't use modules / barrel files, so the import graph is pretty complicated) a no-change incremental build is about 8s with and 3s without circular dependency checking on a state of the art desktop. There is also no easy way to see how much time is spent in the circular dependency plugin, so took a while to figure that out.

Describe the solution you'd like

Ideally the circular dependency check would run asynchronously, like the type checker.

Describe alternatives you've considered

For now, we have a separate build configuration with "showCircularDependencies": false

@dgp1130
Copy link
Collaborator

dgp1130 commented Jan 14, 2021

Thanks for identifying the slow plugin, it's really helpful to have a specific piece of a build to discuss rather than just a general "build is slow". We had a brief discussion about this in our regular tooling triage meeting.

Just for reference, we do have a debug flag for enabling profiling of the Webpack plugins used in a build (doesn't support Webpack 5). This is an internal debug flag, so not a strict public API, but users are welcome to try it, and if it works it might give a little more insight into why a build might be slow:

NG_BUILD_PROFILING=true ng serve

In general, we don't want to remove the circular dependency check solely for performance reasons. Although circular dependencies are allowed by browsers and Node, there are a lot of downsides which aren't totally obvious or an issue until a project hits a certain scale. This includes slower incremental builds, coupled compilation between all files in the cycle, and increased difficulty in extracting a library from a cycle. Bazel, Closure compiler, and google3 in general do not allow circular dependencies at all for these reasons.

If your build is only 3s normally, but spends an additional 5s checking circular dependencies, that sounds like a performance issue with circular-dependency-plugin which could be better fixed there rather than turning it off altogether. As a Webpack plugin, I would expect it should have access to incremental compilation results and be able to cache effectively enough to avoid re-checking the vast majority of unchanged files. Of course, the maintainer(s) of that plugin would be knowledgeable about possible performance improvements. Filing an issue there might be the best way to understand the core problem and whether or not it can be addressed more directly.

As another option, you can drop the Webpack plugin and use an ESLint plugin instead. That would run the circular dependency check asynchronously, although it does say it can be expensive and possibly slow down linting.

Considering there is a showCircularDependencies flag for users to disable this if and when it becomes a problem, we think that is good enough for most projects. If this becomes a more consistent issue in the future, we might revisit our default options, but for now, we'll keep this as is.

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Feb 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants