Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
896 views
in Technique[技术] by (71.8m points)

performance - How to reduce Scala (/ Java) startup overhead?

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...