I decided to give it a try on my Acer Aspire One netbook, which I use often to do some daily tasks. Unfortunately, with 1.6 GHz Intel Atom and 1GB RAM running Fedora 14 it took Scala REPL almost 20 seconds to start. I was wondering if I could make it faster and found out that some people recommended Nailgun for this task. In short, Nailgun preloads the whole JVM into the memory and than uses its own bootstrap loader to connect your programs to it, so that they load much faster, without JVM startup overhead. However, besides some good advice I couldn't find any working example how to do it, so I decided to do it myself. Fortunately it turned out to be a quite easy task. First, I copied nailgun-0.7.1.jar to Scala's lib directory, then I took the original bin/scala script and created a modified version. I changed line 161 from
scala.tools.nsc.MainGenericRunner "$@"to
com.martiansoftware.nailgun.NGServer "$@"and line 113 from
CPSELECT="-Xbootclasspath/a:"to
CPSELECT="-cp "The last change was necessary for Nailgun to load properly. Then I started regular Scala REPL through
ng scala.tools.nsc.MainGenericRunnerjust to learn that it still takes 20 seconds to start. Conclusion? Modern JVM loading overhead is so small that reducing it further makes little sense, even on slow machines.
Lessons learned:
1) Using Nailgun to speed up Scala won't get you anywhere.
2) Don't listen to forum "experts" who recommend solutions which they have obviously never tried in practice.
1 comment:
The funny thing is that on a recent MacBook Pro, it really does speed things up significantly -- REPL shows up almost instantly! So, to your morale of the story, I'd add: test on diverse systems before giving up! :)
Post a Comment