You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
##############################
# comb.rb
def newGap gap
gap /= 1.3;
gap = gap.to_i;
return 11 if gap == 9 or gap == 10
return 1 if gap < 1
gap
end
def combSort a
len = a.length
gap = len
swapped = false
begin
swapped = false
gap = newGap gap
(0...(len-gap)).each do |i|
if a[i] > a[i+gap]
swapped = true
a[i], a[i+gap] = a[i+gap], a[i]
end
end
end while gap > 1 or swapped
end
N = 10000000;
arr = (1..N).to_a.reverse!
combSort arr
(1...N).each do |z|
print '!' if arr[z]<arr[z-1]
end
when using ruby 2.2.0 it works fine, done in less than a minute, rubinius too, less than two minutes, but when using JRuby, it never ends, I wait for about 5 minutes, but it still haven't done yet, and it uses all CPU cores. Is this JRuby's bug?
JRuby version: jruby 1.7.18 (1.9.3p551) 2014-12-22 625381c on OpenJDK 64-Bit Server VM 1.7.0_71-b14 +jit [linux-amd64] and jruby 9.0.0.0.pre1 (2.2.0p0) 2015-01-20 d537cab OpenJDK 64-Bit Server VM 24.65-b04 on 1.7.0_71-b14 +jit [linux-amd64]
The text was updated successfully, but these errors were encountered:
kokizzu
changed the title
JRuby never end
JRuby never end when running this code
Feb 2, 2015
I ran that code on jruby 9.0.0.0.pre1 (2.2.0p0) 2015-01-20 d537cab Java HotSpot(TM) 64-Bit Server VM 25.25-b02 on 1.8.0_25-b17 +jit [linux-amd64] and got an OutOfMemoryError, so I played with the Xmx argument and got the following results:
Memory (-J-Xmx<value>)
Result
256m
OutOfMemory in 25 seconds
500m (default)
OutOfMemory in 45 seconds
768m
100% on all cores for 12 minutes then I aborted the program
1024m
Done in 3 minutes
My guess is that it is too much memory for an OutOfMemoryError but too few to run.
Try changing the that JVM argument and see if something changes.
Resolving this. MRI runs this in 34s on my machine. JRuby runs it as 40s with default params and 33s with compile.invokedynamic. Whatever memory issue we had seems to no longer be an issue any more.
I'm trying to run this script:
when using ruby 2.2.0 it works fine, done in less than a minute, rubinius too, less than two minutes, but when using JRuby, it never ends, I wait for about 5 minutes, but it still haven't done yet, and it uses all CPU cores. Is this JRuby's bug?
JRuby version:
jruby 1.7.18 (1.9.3p551) 2014-12-22 625381c on OpenJDK 64-Bit Server VM 1.7.0_71-b14 +jit [linux-amd64]
andjruby 9.0.0.0.pre1 (2.2.0p0) 2015-01-20 d537cab OpenJDK 64-Bit Server VM 24.65-b04 on 1.7.0_71-b14 +jit [linux-amd64]
The text was updated successfully, but these errors were encountered: