-
-
Notifications
You must be signed in to change notification settings - Fork 119
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
Severe performance degradation after upgrading to 2.2.0 #63
Comments
I'm noticing +5 mins of extra time during different |
Are you a Windows user? The up-to-date detection is slow on Windows, mainly the first time it runs. You are right, in this fork of the original plugin, the inputs and outputs of the tasks were declared so that they run only when necessary and can be cached if the build cache is enabled. The As a workaround, you can ignore the content of the npmInstall {
nodeModulesOutputFilter = { it.exclude("**") }
} I am not sure about the Hope my message will help you! |
In my case, I was on Linux, and the slowness was perceived almost every time. I did not try your workaround yet, as for me this issue became less important. However, it looks to me that the suggested workaround would break correctness. :( |
@rkrisztian, do you know which tasks have been slowed down since you use this fork? I was talking about the fact the I assume you do not use the |
@nemeth-z I did not think about that but you are right. Using the We changed this recently to fix issue #38. We do not have any build cache tests for now, this is the reason why we did not notice that the cache no longer works. We should add some tests to ensure the cache works as expected. I will try to find an issue to get both issue #38 and caching work. |
In my case, my |
@rkrisztian are you able to share a gradle buildscan or the result of --profile? |
@deepy I'll sketch up a test project for you, please give me some time. |
See test-node-perf.zip.
This is exactly what I'm experiencing in a real project but with the mentioned much higher build times when building the project in parallel. However, I am not sure if my problem is related to what was originally reported. |
Thanks @rkrisztian for this project that reproduces this issue. I now understand what's happening. The main project I am working on contains two Angular applications (similar but much bigger than these ones) and I have this severe performance degradation. In fact I am not using the plugin's The performance drop you are facing (and probably @nemeth-z also) seems to be due to the #38 fix. In 8f4d0bb I replaced the I tried to build your project with the version 2.1.1 of this plugin and it is fast (at least on Linux). I did not test it on Windows and I assume it will not be fast because it sounds like using As a workaround, for now, you can either use the 2.1.1 version of this plugin or use a custom task to replace the Thanks for your help! |
I tried both suggestion (2.1.1 and filetree filter) and both solved the performance issue on Win and Linux as well. Thanks for the hints, given that only the 2.2 release notes mentioned Gradle 6 compatibility, I have not considered downgrading. |
Sorry for asking, but do you think it's really a good idea to add up-to-date checks and cacheability to this |
There's no cacheability being added to |
Thanks @rkrisztian for this relevant question.
If we want to make it cacheable, we have to ensure that the cache is compatible with the system, that could be very tricky. So you are right, we probably don't want this task to be cacheable.
I did a small experiment based on your project. As you suggested, I run When I force When using the plugin containing my fix, the On Linux and with this size of project, it appears that Gradle's up-to-date checking is much faster than npm's one. As far as I know, on Windows, Gradle's up-to-date checking is much slower, that would be interesting to make this same experiment. |
I did the same experiment on a Windows VM on my laptop. It appears that Gradle's up-to-date mechanism (using I think that we should let Gradle's up-to-date checking enabled for this task. |
…te detection much slower. We now use @OutputDirectory unless a node_modules output filter is defined.
I created a Could one of you @rkrisztian or @nemeth-z test it please in real conditions before we publish it? Doing that is very simple:
includeBuild "../path/to/gradle-node-plugin" // Don't forget to adjust the path to the gradle-node-plugin repository directory Gradle will understand that this is the source code of the plugin and will use it instead of the jar downloaded from the repository. As it is a Gradle project, it knows how to compile it. |
…te detection much slower. We now use @OutputDirectory unless a node_modules output filter is defined.
I tested with the branch and it works correctly. Checked the commit and I am curious though, what is the use case for using the tree filter (and falling back to output files)? |
Ok, nice! Thanks @nemeth-z! The file tree filter is to fix issue #38. Some npm commands (the Ember.js build in this issue) modify some files of the installed packages in Indeed, when using To fix issue #38, we need a way to tell Gradle to ignore some files. This is the reason why use replaced the |
I see. Thanks for the quick fix and explanation. |
We can probably release 2.2.1, but having moved the output into Although I guess we don't really need that solved before releasing 3.x |
@bsautel I have a plugin that extends the Gradle node plugin with some additional configuration and custom npm tasks. With Gradle 6 and node plugin 2.1.1, the built in verification breaks as some of the properties are not annotated (extending from npmTask that has violations). These problems are already fixed in 2.2 so if possible I would like to use a version containing both fixes. As for afterEval, have you though about a configuration tasks? Basically moving the logic from AfterEval to a task that is depended by the install tasks. |
Ok, I now see what you mean. The version we are ready to release is the equivalent of the 2.2.0 plus the fix of this issue. We did not change anything else. In this coming version, all the properties are annotated and the I talked about the 2.1.1 version above as a temporary workaround until we release a fix because the cause of this performance drop is a change in the 2.2.0 version. @deepy and @nemeth-z, that's right, one more |
To my surprise I no longer be able to find a reference to this approach (which makes me wonder whether it is idiomatic). The idea is roughly:
This way task configuration is pushed to execution time to the latest possible moment, with the added benefit of only doing it when npmInstall is actually executed. |
I think it still is idiomatic but mostly got replaced by Providers and Properties |
My bad, I misunderstood your previous comment about versions, I'll release it in a bit |
@nemeth-z 2.2.1 is available on the plugin portal now, sorry about the delay! |
I am in the process of upgrading a project to Gradle 6 and I was happy to find this maintained fork. After upgrading and switching the plugin, our Angular based module build time is increased by ~10 minutes. After analyzing what is going on, it turned out 95% of the build time is spent on task output overlap detection (scanning files in
node_modules
). There is a recent open Gradle issue about it (gradle/gradle#11792). However this detection was not changed (afaik) with the new release.After started checking the changes in this fork I noticed the node_modules directory is handled differently in the npmInstall task. It went from an output directory to output files, which could be the reason why the overlap detection went haywire. Additionally a file tree is used which according to the docs also disables caching.
I am not sure yet if this the only or even the real issue though.
The text was updated successfully, but these errors were encountered: