如何减少Scala(/ Java)启动开销? [英] How to reduce Scala (/ Java) startup overhead?

查看:192
本文介绍了如何减少Scala(/ Java)启动开销?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对Java世界一无所知(我主要使用C / Python)但Scala看起来很有趣,可以吸引我。我遇到的一个问题是巨大的启动开销 - 最少0.3秒,更多如果我使用解释器而不是编译,相比之下,对于Python或C实际上是0。因此,即使语言比Python快几十倍,如果我试图将它用于简单的任务,它仍然是在实践中要慢得多。



有没有办法减少这个时间,或者它是JVM中不可避免的一部分+ Scala所需(隐式)导入的数量程序?

解决方案

你在使用什么类型的计算机?显然存在JVM启动开销,但如果JVM检测到您正在运行服务器级机器


在J2SE平台5.0版中,一类称为服务器级机器的机器被定义为具有以下内容的机器: p>


  • 2个或更多物理处理器

  • 2个或更多GB物理内存


您可以使用 -client将JVM置于客户端模式 选项。调整客户端模式以缩短启动时间。



还有转向 模块化JVM (项目 Jigsaw )这将进一步缩短启动时间 - 这已经从 JDK 1.6.0_10 开始。


I'm pretty ignorant of the Java world (I do mostly C / Python) but Scala looked interesting enough to pull me in. One problem I'm having with it is the enormous startup overhead - 0.3 seconds minimum, much more if I'm using the interpreter instead of compiling, compared to effectively 0 for Python or C. So even though the language is tens of times faster than Python once it gets going, if I'm trying to use it for simple tasks it's still considerably slower in practice.

Is there any way to reduce this time, or is it an unavoidable part of the JVM + the number of required (implicit) imports for a Scala program?

解决方案

What sort of computer are you using it on? Obviously there is a JVM startup overhead but this is even greater if the JVM detects you are running on a server-class machine.

In the J2SE platform version 5.0 a class of machine referred to as a server-class machine has been defined as a machine with:

  • 2 or more physical processors
  • 2 or more Gbytes of physical memory

You can put the JVM in client mode by using the -client option. The client mode is tuned for fast startup time.

There is also the move to modularize the JVM (project Jigsaw) which will improve startup times even more - this has started with JDK 1.6.0_10.

这篇关于如何减少Scala(/ Java)启动开销?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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