Feng Tian
Posts: 2
Nickname: fengttt
Registered: Aug, 2008
|
|
Re: scala sort performance?
|
Posted: Aug 27, 2008 12:41 PM
|
|
Hi,
Thanks for reply.
val l = (1 to 2000000).toList
takes about 15 seconds or so. This is very slow, but not as bad as sort.
Another problem is that the memory consumption is out of control. top shows java is using 1G virtual memory with 400M resident. 2 Million Int should take 8M. Since it is 2M objects in JVM, let's give it a factor of 10 :-) I cannot understand why this thing goes above 100M. My JAVA_OPTS='-Xmx512M -Xms16M -Xss16M'. Issue the statement twice will out of memory. Ouch!
scala> bash-3.2$ scala Welcome to Scala version 2.7.1.final (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_06). Type in expressions to have them evaluated. Type :help for more information.
scala> val l = (1 to 2000000).toList l: List[Int] = List(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, ... scala> val l = (1 to 2000000).toList java.lang.OutOfMemoryError: Java heap space at scala.StringBuilder$.scala$StringBuilder$$copyOf(StringBuilder.scala:868) at scala.StringBuilder.expandCapacity(StringBuilder.scala:113) at scala.StringBuilder.append(StringBuilder.scala:247) at scala.StringBuilder.append(StringBuilder.scala:235) at RequestResult$.<init>(<console>:4) at RequestResult$.<clinit>(<console>) at Request... scala>
|
|