Project

General

Profile

Actions

Bug #161

closed

Profile library seems broken in 1.9 15427cat t.rv

Added by pragdave (Dave Thomas) over 16 years ago. Updated over 13 years ago.

Status:
Closed
Target version:
-
ruby -v:
Backport:
[ruby-core:17261]

Description

=begin
dave[RUBY3/Book 18:11:11*] cat t.rb
require 'profile'
def ackerman(m, n)
if m == 0 then n+1
elsif n == 0 and m > 0 then ackerman(m-1, 1)
else ackerman(m-1, ackerman(m, n-1))
end
end
ackerman(3, 3)

With 1.8:

dave[RUBY3/Book 18:11:36*] /usr/bin/ruby -v t.rb
ruby 1.8.6 (2007-09-24 patchlevel 111) [universal-darwin9.0]
% cumulative self self total
time seconds seconds calls ms/call ms/call name
72.97 0.27 0.27 2432 0.11 4.65 Object#ackerman
13.51 0.32 0.05 3676 0.01 0.01 Fixnum#==
10.81 0.36 0.04 2431 0.02 0.02 Fixnum#-
2.70 0.37 0.01 1188 0.01 0.01 Fixnum#+
0.00 0.37 0.00 1 0.00 0.00 Module#method_added
0.00 0.37 0.00 57 0.00 0.00 Fixnum#>
0.00 0.37 0.00 1 0.00 370.00 #toplevel

With 1.9:

dave[RUBY3/Book 18:11:40*] ruby -v t.rb
ruby 1.9.0 (2008-06-16 revision 15427) [i686-darwin9.3.0]
% cumulative self self total
time seconds seconds calls ms/call ms/call name
0.00 0.00 0.00 1 0.00 0.00 Module#method_added
0.00 0.01 0.00 1 0.00 10.00 #toplevel
=end

Actions #1

Updated by pragdave (Dave Thomas) over 16 years ago

=begin
I don't know if this is related, but it you add a @puts@, you get a different error...

dave[RUBY3/Book 18:13:48*] cat /tmp/prog.rb
require 'profile'
puts "\footnotesize" # <<< added this line
def ackerman(m, n)
if m == 0
n+1
elsif n == 0 and m > 0
ackerman(m-1, 1)
else
ackerman(m-1, ackerman(m, n-1))
end
end
ackerman(3, 3)
dave[RUBY3/Book 18:14:03*] ruby /tmp/prog.rb
% cumulative self self total
time seconds seconds calls ms/call ms/call name
0.00 0.01 0.00 1 0.00 10.00 #toplevel
/tmp/prog.rb:2:in puts': Can't create Binding Object on top of Fiber. (RuntimeError) from /tmp/prog.rb:2:in puts'
from /tmp/prog.rb:2:in `'

=end

Actions #2

Updated by ko1 (Koichi Sasada) over 16 years ago

=begin
This is a limitation (incompatible feature) on 1.9.

Workaround is to re-defining operators:

class Fixnum
alias orig_plus +
def +(o)
orig_plus(o)
end
end

Dave Thomas wrote:

Issue #161 has been reported by Dave Thomas.


Bug #161: Profile library seems broken in 1.9 15427cat t.rv
http://redmine.ruby-lang.org/issues/show/161

Author: Dave Thomas
Status: Open
Priority: Normal
Assigned to:
Category:
Target version:

dave[RUBY3/Book 18:11:11*] cat t.rb
require 'profile'
def ackerman(m, n)
if m == 0 then n+1
elsif n == 0 and m > 0 then ackerman(m-1, 1)
else ackerman(m-1, ackerman(m, n-1))
end
end
ackerman(3, 3)

With 1.8:

dave[RUBY3/Book 18:11:36*] /usr/bin/ruby -v t.rb
ruby 1.8.6 (2007-09-24 patchlevel 111) [universal-darwin9.0]
% cumulative self self total
time seconds seconds calls ms/call ms/call name
72.97 0.27 0.27 2432 0.11 4.65 Object#ackerman
13.51 0.32 0.05 3676 0.01 0.01 Fixnum#==
10.81 0.36 0.04 2431 0.02 0.02 Fixnum#-
2.70 0.37 0.01 1188 0.01 0.01 Fixnum#+
0.00 0.37 0.00 1 0.00 0.00 Module#method_added
0.00 0.37 0.00 57 0.00 0.00 Fixnum#>
0.00 0.37 0.00 1 0.00 370.00 #toplevel

With 1.9:

dave[RUBY3/Book 18:11:40*] ruby -v t.rb
ruby 1.9.0 (2008-06-16 revision 15427) [i686-darwin9.3.0]
% cumulative self self total
time seconds seconds calls ms/call ms/call name
0.00 0.00 0.00 1 0.00 0.00 Module#method_added
0.00 0.01 0.00 1 0.00 10.00 #toplevel


You have received this notification because you have either subscribed to it, or are involved in it.
To change your notification preferences, please click here: http://redmine.ruby-lang.org/my/account

--
// SASADA Koichi at atdot dot net

=end

Actions #3

Updated by pragdave (Dave Thomas) over 16 years ago

=begin
Should I document this as a workaround when I talk about profiling, or will it be fixed before 1.9 goes final?

Dave
=end

Actions #4

Updated by ko1 (Koichi Sasada) over 16 years ago

=begin
Hi,

Dave Thomas wrote:

Should I document this as a workaround when I talk about profiling, or will it be fixed before 1.9 goes final?

This is "1.9" feaure. At least, Matz accept it.
I'm not sure that it should be written.

--
// SASADA Koichi at atdot dot net

=end

Actions #5

Updated by pragdave (Dave Thomas) over 16 years ago

=begin
[Dave Thomas wrote:] Should I document this as a workaround when I talk about profiling, or will it be fixed before 1.9 goes final?

[SASADA Koichi wrote:] This is "1.9" feaure. At least, Matz accept it. I'm not sure that it should be written.

But the profile library is distributed with 1.9, and it doesn't work because of this change. I think that counts as a bug, not a feature. If it isn't a bug in the interpreter, then surely the library has to be adapted to work or removed from the standard distribution.
=end

Actions #6

Updated by ko1 (Koichi Sasada) over 16 years ago

=begin
Hi,

Dave Thomas wrote:

But the profile library is distributed with 1.9, and it doesn't work because of this change. I think that counts as a bug, not a feature. If it isn't a bug in the interpreter, then surely the library has to be adapted to work or removed from the standard distribution.

I have misunderstood. I thought your point is "Fixnum#+ is not
appeared". But your point is "There isn't Object#ackerman on a
profile result", isn't it?

Former is a feature. Latter is a bug.

--
// SASADA Koichi at atdot dot net

=end

Actions #7

Updated by ko1 (Koichi Sasada) over 16 years ago

  • Assignee set to ko1 (Koichi Sasada)

=begin

=end

Actions #8

Updated by rogerdpack (Roger Pack) over 16 years ago

=begin
ruby-prof seems to at least somewhat work.

~/dev/ruby_1_9_svn ruby-prof go.rb
Thread ID: 214780
Total: 0.058815

%self total self wait child calls name
12.782 0.008 0.008 0.000 0.000 3676 Fixnum#==
8.449 0.005 0.005 0.000 0.000 2431 Fixnum#-
4.133 0.002 0.002 0.000 0.000 1188 Fixnum#+
1.872 0.037 0.001 0.000 0.036 61 Object#ackerman-22
1.865 0.043 0.001 0.000 0.042 61 Object#ackerman-18
1.863 0.030 0.001 0.000 0.029 61 Object#ackerman-27
...

=end

Actions #9

Updated by ko1 (Koichi Sasada) over 16 years ago

  • Status changed from Open to Closed

=begin

=end

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0