Re: [MacRuby-devel] [MacRuby] #424: performance regression from ruby 1.8 and 1.9

2009-11-10 Thread MacRuby
#424: performance regression from ruby 1.8 and 1.9
-+--
 Reporter:  jordan.breed...@…|   Owner:  lsansone...@…
 Type:  defect   |  Status:  new  
 Priority:  blocker  |   Milestone:   
Component:  MacRuby  |Keywords:   
-+--

Comment(by jordan.breed...@…):

 Another example (I think this file is the worst case for my sample
 program):

 {{{
 12 jor...@thetourist ...tificial Intelligence/Assignment No.
 1/priority_queue_bug > for LOOP in ruby ruby1.9 macruby; do eval time
 "${LOOP}" ./search.pqueue -m -c a-star input_files/input13_1.txt
 >/dev/null; done
 ruby ./search.pqueue -m -c a-star input_files/input13_1.txt  12.22s user
 0.19s system 99% cpu 12.513 total
 ruby1.9 ./search.pqueue -m -c a-star input_files/input13_1.txt  7.10s user
 0.13s system 99% cpu 7.251 total
 macruby ./search.pqueue -m -c a-star input_files/input13_1.txt  34.86s
 user 1.52s system 180% cpu 20.195 total
 }}}

-- 
Ticket URL: 
MacRuby 

___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel


Re: [MacRuby-devel] [MacRuby] #424: performance regression from ruby 1.8 and 1.9

2009-11-10 Thread MacRuby
#424: performance regression from ruby 1.8 and 1.9
-+--
 Reporter:  jordan.breed...@…|   Owner:  lsansone...@…
 Type:  defect   |  Status:  new  
 Priority:  blocker  |   Milestone:   
Component:  MacRuby  |Keywords:   
-+--

Comment(by mattaimone...@…):

 Jordan, could you please find out what exactly is slower in your script?
 If you can extract it out it will be easier to work on the isolated piece
 of code that's slower.

 Thanks,

 - Matt

-- 
Ticket URL: 
MacRuby 

___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel


[MacRuby-devel] [MacRuby] #429: Floating point comparison

2009-11-10 Thread MacRuby
#429: Floating point comparison
+---
 Reporter:  jens.nock...@…  |   Owner:  lsansone...@…
 Type:  defect  |  Status:  new  
 Priority:  trivial |   Milestone:   
Component:  MacRuby |Keywords:   
+---
 Some floating point comparisons seem to be giving different results in
 MacRuby and in MRI.

 macirb > (0.5 - 0.4) <= 0.1
   => false
 mriirb > (0.5 - 0.4) <= 0.1
   => true

-- 
Ticket URL: 
MacRuby 

___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel


Re: [MacRuby-devel] [MacRuby] #424: performance regression from ruby 1.8 and 1.9

2009-11-10 Thread MacRuby
#424: performance regression from ruby 1.8 and 1.9
-+--
 Reporter:  jordan.breed...@…|   Owner:  lsansone...@…
 Type:  defect   |  Status:  new  
 Priority:  blocker  |   Milestone:   
Component:  MacRuby  |Keywords:   
-+--

Comment(by jordan.breed...@…):

 Well, unless I am losing my mind it must be something to do with iterating
 over things in MacRuby. I say this because even in the example below the
 amount of nodes being pushed onto the queue should be dominated by all of
 the other work going on, almost eliminating performance differences of the
 queue itself.

 {{{
 57 jor...@thetourist ~/priority_queue_bug > for LOOP in search.*; do eval
 time macruby "${LOOP}" -c -m a-star input_files/input13_1.txt >/dev/null;
 done
 macruby search.cocoa -c -m a-star input_files/input13_1.txt  33.69s user
 1.58s system 182% cpu 19.363 total
 macruby search.pqueue -c -m a-star input_files/input13_1.txt  35.01s user
 1.49s system 179% cpu 20.278 total
 }}}

 However, if I use two new scripts that are strictly adding a large amount
 of nodes the the queue the difference is greater, in this case the .pqueue
 file would still be taking the hit of iterating, etc. strictly on the
 MacRuby side (where MacRuby appears to be slower than 1.8 or 1.9), the
 .cocoa example ends up doing most of the heaving lifting in this case
 through CFBinaryHeap.

 Here are ruby, ruby1.9, and macruby using the .pqueue file:

 {{{
 62 jor...@thetourist ~/priority_queue_bug > for LOOP in ruby ruby1.9
 macruby; do eval time "${LOOP}" ./speed_test.pqueue; done
 ruby ./speed_test.pqueue  82.38s user 3.10s system 96% cpu 1:28.39 total
 ruby1.9 ./speed_test.pqueue  55.25s user 3.02s system 99% cpu 58.845 total
 macruby ./speed_test.pqueue  69.08s user 11.54s system 47% cpu 2:49.53
 total
 }}}

 Here is macruby using the .pqueue file and the .cocoa file:

 {{{
 63 jor...@thetourist ~/priority_queue_bug > for LOOP in speed_test.*; do
 eval time macruby "${LOOP}"; done
 macruby speed_test.cocoa  6.73s user 0.34s system 117% cpu 6.005 total
 macruby speed_test.pqueue  65.32s user 10.76s system 50% cpu 2:31.36 total
 }}}

 Here is the .pqueue file:

 {{{
 #!/usr/bin/env ruby1.9

 # put the directory this file is in into the search path so that we
 # can get ruby_priority_queue below

 $:.unshift(File.dirname($0))

 require 'lib/revision'
 require 'lib/pqueue'

 if (Revision.new(RUBY_VERSION) < Revision.new("1.9"))
 class String
 def chars
 return self.split("")
 end
 end
 end

 class TestNode
 include Comparable

 attr_reader :priority

 def initialize(newPriority)
 $counter = $counter + 1
 @priority = newPriority
 end

 def <=>(rhs)
 @priority <=> rhs.priority
 end

 def getChildren
 (@priority * 5).upto((@priority * 5) + 2).map { |childPriority|
 TestNode.new(childPriority)
 }
 end
 end

 $counter = 0

 $searchQueue = PQueue.new
 $searchQueue.push(TestNode.new(0))

 while ((currentNode = $searchQueue.pop) && ($counter < 25)) do
 currentNode.getChildren.each { |child|
 $searchQueue.push(child)
 }
 end

 exit 0
 }}}

 Here is the .cocoa file:

 {{{
 #!/usr/bin/env macruby

 # put the directory this file is in into the search path so that we
 # can get ruby_priority_queue below

 $:.unshift(File.dirname($0))

 require 'lib/revision'

 framework 'lib/JBBPriorityQueue.framework'

 if (Revision.new(RUBY_VERSION) < Revision.new("1.9"))
 class String
 def chars
 return self.split("")
 end
 end
 end

 class TestNode
 include Comparable

 attr_reader :priority

 def initialize(newPriority)
 $counter = $counter + 1
 @priority = newPriority
 end

 def <=>(rhs)
 @priority <=> rhs.priority
 end

 def compareToNode(rhs)
 @priority <=> rhs.priority
 end

 def getChildren
 (@priority * 5).upto((@priority * 5) + 2).map { |childPriority|
 TestNode.new(childPriority)
 }
 end
 end

 $counter = 0

 $searchQueue = JBBPriorityQueue.alloc.init
 $searchQueue.push(TestNode.new(0))

 while ((currentNode = $searchQueue.pop) && ($counter < 25)) do
 currentNode.getChildren.each { |child|
 $searchQueue.push(child)
 }
 end

 exit 0
 }}}

 The library files are in the attached zip file already, these files were
 run from that directory.

 I will keep looking for other places in my main script that might have
 large differences between ruby, ruby1.9, and macruby. Please let me know
 if there is anything else I can specifically look for.

-- 
Ticket URL: 
MacRuby 

Re: [MacRuby-devel] [MacRuby] #424: performance regression from ruby 1.8 and 1.9

2009-11-10 Thread MacRuby
#424: performance regression from ruby 1.8 and 1.9
-+--
 Reporter:  jordan.breed...@…|   Owner:  lsansone...@…
 Type:  defect   |  Status:  new  
 Priority:  blocker  |   Milestone:   
Component:  MacRuby  |Keywords:   
-+--

Comment(by mattaimone...@…):

 > Please let me know if there is anything else I can specifically look
 for.

 Can you break it down to a smaller example really showing where the
 problem is without requiring your script?

 Thanks,

 - Matt

-- 
Ticket URL: 
MacRuby 

___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel


Re: [MacRuby-devel] [MacRuby] #424: performance regression from ruby 1.8 and 1.9

2009-11-10 Thread MacRuby
#424: performance regression from ruby 1.8 and 1.9
-+--
 Reporter:  jordan.breed...@…|   Owner:  lsansone...@…
 Type:  defect   |  Status:  new  
 Priority:  blocker  |   Milestone:   
Component:  MacRuby  |Keywords:   
-+--

Comment(by jordan.breed...@…):

 I can look into it more later, the ones posted above actually only require
 two smallish ruby files out of the lib directory from my archive, I could
 just paste them into the top of the other file and upload it as a new
 attachment if that would help in any way.

 In the mean time I used DTrace to get some timings for functions/methods
 from ruby and MacRuby

 ruby:

 {{{
 13 jor...@thetourist ~/priority_queue_bug > sudo dtrace -s
 ruby_method_analysis.d -c "ruby ./search.pqueue -m -c a-star
 input_files/input13_4.txt"
 Password:
 Target pid: 352


 Step 0: bbwxbwbwbwwbw (c=0)
 Step 1: move  6 bbwbbwxwbwwbw (c=3)
 Step 2: move  5 bbwbbxwwbwwbw (c=1)
 Step 3: move  8 bbwbbbwwxwwbw (c=3)
 Step 4: move  2 bbxbbbwbw (c=6)
 Step 5: move 11 bbwxw (c=9)
 Step 6: move  6 bbxww (c=5)


CLASS   METHOD
 COUNTAVG(us)  SUM(us)
 
---
   String   split
 3298 36   121861
   IO   write
 16 19  307
   String   %
 6 16   98
Exception   initialize
 1 16   16
  JBBNodePriority   initialize
 3308 1653831
Exception   set_backtrace
 1 15   15
Range   each
 3299 1551517
   String   initialize_copy
 42886 14   619271
Exception   backtrace
 1 14   14
   Fixnum   to_s
 15 14  213
  JBBNode   priority
 38826 14   544505
  JBBNode   to_s
 7 13   97
 Hash   []=
 381 13 5291
 Hash   include?
 8629 13   117828
   String   index
 3298 1344610
   String   length
 3300 1343452
   String   []=
 79176 13  1034814
Array   push
 381 13 4971
Array   to_a
 3299 1242753
Array   []=
 18440 12   237676
   Fixnum   div
 7236 1293047
   Fixnum   <=>
 5068 1264921
   String   ==
 53172 12   679790
Array   []
 87152 12  1109695
   String   []
 79176 12  1007480
   Fixnum   ==
 42887 12   544730
   Fixnum   abs
 20086 12   255014
   Fixnum   /
 9894 12   125471
 Hash   []
 16788 12   211988
   Fixnum   >
 31024 12   390794
   Fixnum   *
 21067 12   264933
   Fixnum   <
 28374 12   355145
   Fixnum   -
 24145 12   302109
   Fixnum   +
 81377 12  1017731
 }}}

 MacRuby:

 {{{
 14 jor...@thetourist ~/priority_queue_bug > sudo dtrace -s
 macruby_method_analysis.d -c "macruby ./search.pqueue -m -c a-star
 input_files/input13_4.txt"
 Target pid: 360


 Step 0: bbwxbwbwbwwbw (c=0)
 Step 1: move  6 bbwbbwxwbwwbw (c=3)
 Step 2: move  5 bbwbbxwwbwwbw (c=1)
 Step 3: move  8 bbwbbbwwxwwbw (c=3)
 Step 4: move  2 bbxbbbwbw (c=6)
 Step 5: move 11 bbwxw (c=9)
 Step 6: move  6 bbxww (c=5)


CLASS   METHOD
 COUNTAVG(us)  SUM(us)
 

Re: [MacRuby-devel] [MacRuby] #424: performance regression from ruby 1.8 and 1.9

2009-11-10 Thread MacRuby
#424: performance regression from ruby 1.8 and 1.9
-+--
 Reporter:  jordan.breed...@…|   Owner:  lsansone...@…
 Type:  defect   |  Status:  new  
 Priority:  blocker  |   Milestone:   
Component:  MacRuby  |Keywords:   
-+--

Comment(by jordan.breed...@…):

 Another interesting data point: The stripped down test that just generates
 and inserts X number of nodes and pops some along the way (to generate new
 nodes) always runs incredibly fast when using the CFBinaryHeap version of
 the script:

 {{{
 54 jor...@thetourist ~/priority_queue_bug > for LOOP in
 *_{125,187,218,250}.cocoa; do eval time macruby "${LOOP}"; done
 macruby speed_test_125.cocoa  3.45s user 0.17s system 145% cpu 2.495 total
 macruby speed_test_187.cocoa  4.97s user 0.22s system 150% cpu 3.457 total
 macruby speed_test_218.cocoa  5.92s user 0.26s system 152% cpu 4.060 total
 macruby speed_test_250.cocoa  6.85s user 0.29s system 153% cpu 4.657 total
 }}}

 When running the pure ruby version it is slower, and periodically can even
 be slower than ruby and ruby1.9, which are both fairly consistent, even
 with large data sets (250,000 items):

 {{{
 ruby speed_test_250.pqueue  81.52s user 2.80s system 99% cpu 1:24.36 total
 ruby speed_test_250.pqueue  81.48s user 2.82s system 99% cpu 1:24.40 total
 ruby speed_test_250.pqueue  81.77s user 3.03s system 99% cpu 1:24.86 total
 ruby speed_test_250.pqueue  81.51s user 2.89s system 99% cpu 1:24.44 total
 }}}

 while the MacRuby version tends to fluctuate, especially with large data
 sets, the interesting part is that when it is slower with large data sets
 it is using a decent amount of memory (at least according to iStat Menus),
 and not as much CPU, possibly an issue with garbage collection?

 {{{
 macruby speed_test_250.pqueue  76.62s user 9.61s system 160% cpu 53.618
 total
 macruby speed_test_250.pqueue  78.58s user 9.93s system 159% cpu 55.512
 total
 macruby speed_test_250.pqueue  82.74s user 13.04s system 98% cpu 1:36.89
 total
 macruby speed_test_250.pqueue  78.36s user 11.76s system 58% cpu 2:33.71
 total
 }}}

 The _125 variant generates 125000 nodes, _187 generates 187500 nodes, _218
 generates 218750 nodes, 250 generates 25 nodes.

 MacRuby tends to perform more slowly with large data sets with several
 applications open, but not doing anything (they are taking up memory, but
 not CPU). In the same scenario the timings for ruby and ruby1.9 are still
 consistent and ruby1.9 still performs quickly.

-- 
Ticket URL: 
MacRuby 

___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel


Re: [MacRuby-devel] [MacRuby] #424: performance regression from ruby 1.8 and 1.9

2009-11-10 Thread MacRuby
#424: performance regression from ruby 1.8 and 1.9
-+--
 Reporter:  jordan.breed...@…|   Owner:  lsansone...@…
 Type:  defect   |  Status:  new  
 Priority:  blocker  |   Milestone:   
Component:  MacRuby  |Keywords:   
-+--

Comment(by jordan.breed...@…):

 Just tried a new version that generates 30 nodes.

 ruby and ruby1.9 end up slowing down significantly, memory usage is way
 up, cpu is down, macruby doesn't even finish running:

 {{{
 60 jor...@thetourist ~/priority_queue_bug > for LOOP in ruby ruby1.9
 macruby; do eval time "${LOOP}" ./speed_test_300.pqueue; done
 ruby ./speed_test_300.pqueue  124.68s user 5.30s system 56% cpu 3:50.52
 total
 ruby1.9 ./speed_test_300.pqueue  80.61s user 7.13s system 47% cpu 3:05.52
 total
 macruby(1524,0x7fff70940be0) malloc: *** auto malloc[1524]: agc error: Can
 not allocate new region
 2009-11-10 22:30:32.742 macruby[1524:903] -[Bignum message]: unrecognized
 selector sent to instance 0x200088220
 2009-11-10 22:30:34.888 macruby[1524:903] *** Terminating app due to
 uncaught exception 'NoMethodError', reason: 'undefined method `message'
 for #'
 *** Call stack at first throw:
 (
 0   CoreFoundation  0x7fff80849444
 __exceptionPreprocess + 180
 1   libobjc.A.dylib 0x7fff881a60f3
 objc_exception_throw + 45
 2   libmacruby.dylib0x00010017aef5
 rb_vm_raise + 437
 3   libmacruby.dylib0x000100040f79
 rb_exc_raise + 9
 4   libmacruby.dylib0x00010017a350
 rb_vm_method_missing + 560
 5   libmacruby.dylib0x00010015fbcc
 rb_vm_call_with_cache2 + 5740
 6   libmacruby.dylib0x000100161a34
 
_ZL14method_missingmP13objc_selectorP11rb_vm_blockiPKm29rb_vm_method_missing_reason_t
 + 324
 7   libmacruby.dylib0x0001001623cd
 rb_vm_call + 2125
 8   libmacruby.dylib0x0001001796c3
 rb_vm_print_current_exception + 99
 9   macruby 0x00010dec main +
 172
 10  macruby 0x00010d34 start +
 52
 )
 terminate called after throwing an instance of 'NSException'
 zsh: abort  macruby ./speed_test_300.pqueue
 macruby ./speed_test_300.pqueue  69.00s user 15.48s system 27% cpu 5:03.12
 total
 }}}

-- 
Ticket URL: 
MacRuby 

___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel


Re: [MacRuby-devel] [MacRuby] #424: performance regression from ruby 1.8 and 1.9

2009-11-10 Thread MacRuby
#424: performance regression from ruby 1.8 and 1.9
-+--
 Reporter:  jordan.breed...@…|   Owner:  lsansone...@…
 Type:  defect   |  Status:  new  
 Priority:  blocker  |   Milestone:   
Component:  MacRuby  |Keywords:   
-+--

Comment(by lsansone...@…):

 There is definitely something wrong going on but I have higher priority
 bugs to fix at this point and can't help you now. If you want to help you
 may want to use shark and identify the slow code paths. Try to reproduce
 the performance problems with a small snippet and let us know of what you
 find.

-- 
Ticket URL: 
MacRuby 

___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel


Re: [MacRuby-devel] [MacRuby] #424: performance regression from ruby 1.8 and 1.9

2009-11-10 Thread MacRuby
#424: performance regression from ruby 1.8 and 1.9
-+--
 Reporter:  jordan.breed...@…|   Owner:  lsansone...@…
 Type:  defect   |  Status:  new  
 Priority:  blocker  |   Milestone:   
Component:  MacRuby  |Keywords:   
-+--

Comment(by jordan.breed...@…):

 Here is a shark profile, I was running 10.6.2 and MacRuby is git revision
 "git commit 554fe2e5930a8c5cb8d0f798cfb1d3e1cec8b378", it was 2 MB, so I
 am just linking to it.

 [http://files.me.com/jordan.breeding/zr9gjj Shark Profile]

-- 
Ticket URL: 
MacRuby 

___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel