[ruby-core:114505] [Ruby master Bug#17383] 3.0 recursion memory|speed issues

Issue #17383 has been updated by jeremyevans0 (Jeremy Evans). Status changed from Open to Closed I tested the example: * 2.7: 1178 seconds * 3.2: 1315 seconds * 3.2 --yjit: 1012 seconds 3.2 with --yjit is ~15% faster than 2.7, so whatever performance has been lost since 2.7 has been more than regained by --yjit. ---------------------------------------- Bug #17383: 3.0 recursion memory|speed issues https://bugs.ruby-lang.org/issues/17383#change-104294 * Author: jzakiya (Jabari Zakiya) * Status: Closed * Priority: Normal * Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN ---------------------------------------- Testing 3.0.0-preview2 against 2.7.2 I see it's still not as performant to 2.7.2 for the following code. Below is code from Rosettacode.org https://rosettacode.org/wiki/Palindromic_gapful_numbers#Orders_of_Magnitude_... This is run on an I7, 3.5GHz, 16GB, Linux 5.9.10 laptop. Using rvm, 2.7.2 uses at max ~50% of memory worst case, but for 3.0.0pre2 it hits ~70%. It's also faster on 2.7.2 than 3.0.0-pre2 ``` class PalNo def initialize(digit) @digit, @l, @dd = digit, 3, 11*digit end def fN(n) return [0,1,2,3,4,5,6,7,8,9] if n==1 return [0,11,22,33,44,55,66,77,88,99] if n==2 a=[]; [0,1,2,3,4,5,6,7,8,9].product(fN(n-2)).each{ |g| a << g[0]*10**(n-1)+g[0]+10*g[1] }; return a end def show(count, keep) to_skip, palcnt, pals = count - keep, 0, [] while palcnt < count fN(@l-2).each{ |g| pal=@digit*10**(@l-1)+@digit+10*g; pals << pal if pal%(@dd)==0 && (palcnt += 1) > to_skip; break if palcnt - to_skip == keep }; @l+=1 end print pals; puts end end start = Time.now (1..9).each { |digit| PalNo.new(digit).show(20, 20) }; puts "####" (1..9).each { |digit| PalNo.new(digit).show(100, 15) }; puts "####" (1..9).each { |digit| PalNo.new(digit).show(1000, 10) }; puts "####" (1..9).each { |digit| PalNo.new(digit).show(100_000, 1) }; puts "####" (1..9).each { |digit| PalNo.new(digit).show(1_000_000, 1) }; puts "####" (1..9).each { |digit| PalNo.new(digit).show(10_000_000, 1) }; puts "####" puts (Time.now - start) ``` -- https://bugs.ruby-lang.org/
participants (1)
-
jeremyevans0 (Jeremy Evans)