[ 
https://issues.apache.org/jira/browse/CB-13767?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16517564#comment-16517564
 ] 

Raphael commented on CB-13767:
------------------------------

Whenever _cordova-lib_ decides that it needs some Cordova plugin or platform, 
it calls _cordova-fetch_ with the _spec_ (e.g. _foo@1.2.3_ or _github:foo/bar_) 
to get a path to the installed package.

Until I made the recent performance patch to cordova-fetch, it would just 
install the required dependency using npm and return the path to the installed 
package to cordova-lib.

With my patch cordova-fetch first checks if the required dependency is already 
installed and returns the path to the installed version if it satisfies the 
version constraints passed by cordova-lib. For this, we _need_ to determine the 
required package's name. And with a Git spec, the only way to do that is to 
install the package. Tough luck.

Consequently, every git dependency you have will be installed _every time_ 
cordova-lib feels like calling cordova-fetch with its spec. And If your 
dependency's repository isn't hosted by one of the major Git hosters (GitHub, 
GitLab, ...) npm won't even do a shallow clone, since it can't be sure that 
it's supported by the remote side.

So that's why Git dependencies kill performance.

Now please know, that I'm aware that you sometimes simply _need_ to depend on 
packages by specifying a Git URL. Moreover, I too think that Cordova should not 
have to do package management and dependency resolution. It's a major PITA, 
believe me. But also know, that we can't simply flip a switch and all will be 
well. It's a little bit more complicated than that.

The improvement in cordova-fetch is something we could do _now_ and with a 
_reasonable amount of work_. We will continue to investigate on how to further 
improve performance as our time allows. After all, Cordova is improved by 
people volunteering their time.

> Huge performance issues moving from cordova 6.5 to 8 due to cordova-fetch
> -------------------------------------------------------------------------
>
>                 Key: CB-13767
>                 URL: https://issues.apache.org/jira/browse/CB-13767
>             Project: Apache Cordova
>          Issue Type: Improvement
>          Components: cordova-lib
>            Reporter: Andrew Crites
>            Priority: Major
>
> This is for a project with a wide variety of plugins ... about 25. This may 
> be above average, but not extreme. I've updated the project from cordova 6.5 
> to cordova 8. Cordova 8 always uses {{cordova-fetch}} to install plugins, so 
> I can't opt out. Before, I was not using {{cordova-fetch}}.
> {code}
> $ time npx cordova@6.5 platform add ios
>   23.85s user 9.26s system 130% cpu 25.414 total
> $ time npx cordova@8 platform add ios --nosave
>   402.44s user 61.94s system 119% cpu 6:28.09 total
> {code}
> That takes over 15 times longer. {{--nosave}} was used since this is the 
> default behavior for 6.5.
> For subsequent installations using {{--save}} (or default) the performance is 
> still like this.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org
For additional commands, e-mail: issues-h...@cordova.apache.org

Reply via email to