为什么ember-cli太慢了 [英] Why the ember-cli is so slow

查看:130
本文介绍了为什么ember-cli太慢了的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我把我的咕噜计划迁移到了ember-cli,我发现从文件修改到活载完成的时间已经很长了,大约10分钟。在安装ember-cli-windows之后,ember-cli-windows-addon,没有明显的提示。以下是ember-cli-windows,ember-cli-windows-addon安装后的一个示例输出:

  \\services.js 

构建成功 - 382781ms。

最慢的树|总计
--------------------------------------------- - + ---------------------
Babel | 82175ms
Concat:Vendor | 75980ms
漏斗:应用程序JS文件| 57393ms
JSHint app- QUnit | 49491ms
ES6:App Tree | 41827ms

最慢的树(累积)|总计(平均)
------------------------------------------ ---- + ---------------------
巴别塔(2)| 82394ms(41197 ms)
Concat:Vendor(1)| 75980ms
漏斗:应用程序JS文件(1)| 57393ms
JSHint app- QUnit(1)| 49491ms
ES6:应用程序树(1)| 41827ms

相比之下,构建过程可以在文件修改后的2〜3秒钟内完成。



我使用Windows 7。

解决方案

你问


为什么ember-cli太慢了


这是不是很快,这是西兰花。原因包括:


  1. 西兰花在Windows下复制文件而不是符号链接。为了避免这种情况,请在具有管理员权限的命令提示符下运行您的构建。


  2. 西兰花是磁盘密集型的。为了解决这个问题,得到一个SSD。


  3. 西兰花是处理器密集型的。要解决这个问题,可以获得更快的机器(最好是非Windows)。


  4. 西兰花在 tmp 中创建大量临时文件,这可能会降低性能。要解决这个问题,请不时地清除 tmp


  5. 西兰花被认为是本来就很慢。您可以在西兰花网站上找到相关问题。为了解决这个问题,等待西兰花人们解决性能问题,这正是他们的路线图。已经做了大量的改进,所以升级到最新版本的一切。


  6. 西兰花一遍又一遍地重建了一切,包括没有改变的东西。要解决这个问题,请手动调整构建过程以排除某些事情,并根据需要手动执行。例如,假设您通过bower引入了一个200KB的外部JS包,并将 app.import 加载到您的 Brocfile.js 。作为一个临时的解决方案,要查看是否有所作为,请从Broccoli世界中删除该文件,并将其直接加载到 index.html 中。同样适用于大型CSS文件。


  7. 西兰花将在默认安装中运行babel。巴别不是那么慢,但是确实需要时间。要解决这个问题,如果您不使用ES6语法,请删除babel依赖关系。


  8. 您的病毒扫描程序可能正在尝试扫描西兰花创建的数千个文件。 ember-cli-windows 仅针对Defender处理此问题。如果您正在使用不同的防病毒软件包,要解决这个问题,可以将您的dev目录添加到要跳过的位置列表中。


为了您的参考,我有一个小型的Ember项目,我在一个Ubuntu Virtual Box VM中搭载了Windows主机,搭载了一个带有SSD的快速机器,并且构建需要2-3秒钟。



您也可以考虑在ember-cli列表中询问。您也可以选择一个不会在不成熟和低效的构建系统中烘烤的不同框架。


I migrated my grunt project to ember-cli, I found the time from file modification to liveload completion was so long, about 10 minutes.

After I installed ember-cli-windows, ember-cli-windows-addon, no obvious prompt was gained. The following is one example output after ember-cli-windows, ember-cli-windows-addon installed:

file changed routes\services.js

Build successful - 382781ms.

Slowest Trees                                 | Total
----------------------------------------------+---------------------
Babel                                         | 82175ms
Concat: Vendor                                | 75980ms
Funnel: App JS Files                          | 57393ms
JSHint app- QUnit                             | 49491ms
ES6: App Tree                                 | 41827ms

Slowest Trees (cumulative)                    | Total (avg)
----------------------------------------------+---------------------
Babel (2)                                     | 82394ms (41197 ms)
Concat: Vendor (1)                            | 75980ms
Funnel: App JS Files (1)                      | 57393ms
JSHint app- QUnit (1)                         | 49491ms
ES6: App Tree (1)                             | 41827ms

By contrast, the build process can be finished in 2~3 seconds in grunt project after file modification.

I use windows 7.

解决方案

You ask

Why the ember-cli is so slow

It is not ember-cli per se that is slow, it is Broccoli. Reasons include:

  1. Broccoli copies files instead of symlinking under Windows. To avoid this, run your builds in a command prompt with administrator privileges.

  2. Broccoli is disk-intensive. To solve this, get an SSD.

  3. Broccoli is processor intensive. To solve this, get a faster machine (preferably non-Windows).

  4. Broccoli creates huge numbers of temporary files in tmp, which can slow down performance. To solve this, clean out tmp from time to time.

  5. Broccoli is known to be inherently slow. You can find relevant questions on the broccoli site. To solve this, wait for the broccoli people to address performance issues, which is on their roadmap. Substantial improvements have already been made, so upgrade to the latest version of everything.

  6. Broccoli rebuilds everything over and over again, including things which did not change. To solve this, manually tweak your build process to exclude certain things and do them manually as-needed. For instance, let's say you are bringing in a 200KB external JS package via bower, and app.import'ing it in your Brocfile.js. As a temporary work-around, and to see if it makes a difference, remove that file from the Broccoli world and load it directly in index.html. The same applies to large CSS files.

  7. Broccoli will run babel in a default installation. Babel is not that slow, but it does take time. To solve this, if you are not using ES6 syntax, remove the babel dependency.

  8. Your virus scanner may be trying to scan the thousands of files Broccoli creates. ember-cli-windows deals with this problem only for Defender. If you are using a different anti-virus package, to solve this add your dev directory to its list of places to skip.

For your reference, I have a small Ember project I build in an Ubuntu Virtual Box VM with Windows host on a fast machine with SSD, and builds take 2-3 seconds.

You may also want to consider asking this on an ember-cli list. You could also choose a different framework that does not bake in an immature and inefficient build system.

这篇关于为什么ember-cli太慢了的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆