Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Odd call stack nesting in Ruby 2.7.0 and 2.7.1 #279

Closed
MacksMind opened this issue Sep 1, 2020 · 8 comments
Closed

Odd call stack nesting in Ruby 2.7.0 and 2.7.1 #279

MacksMind opened this issue Sep 1, 2020 · 8 comments

Comments

@MacksMind
Copy link

In the code below, I didn't expect a big change between Ruby 2.6.6 and 2.7.1. In practice, calling 100.times { SecureRandom.gen_random(10) } doesn't change, but calling 100.times { SecureRandom.uuid } changes dramatically.

#!/usr/bin/env ruby

require 'bundler/inline'
require 'securerandom'

gemfile do
  source 'https://rubygems.org'
  gem 'ruby-prof', git: 'https://github.com/ruby-prof/ruby-prof'
end

uuid = RubyProf::Profile.new
uuid.exclude_methods!(Integer, :times)
uuid.start
100.times { SecureRandom.uuid }
uuid.stop

File.open('uuid.html', 'w') do |f|
  RubyProf::CallStackPrinter.new(uuid).print(f)
end

gen_random = RubyProf::Profile.new
gen_random.exclude_methods!(Integer, :times)
gen_random.start
100.times { SecureRandom.gen_random(10) }
gen_random.stop

File.open('gen_random.html', 'w') do |f|
  RubyProf::CallStackPrinter.new(gen_random).print(f)
end
@cfis
Copy link
Member

cfis commented Sep 2, 2020

Can you attach the results you are seeing? What's different?

@MacksMind
Copy link
Author

It won't let me upload the html, but here's a screenshot with Ruby 2.6.6 on the left, and 2.7.1 on the right.

Screen Shot 2020-09-02 at 7 12 31 AM

@cfis
Copy link
Member

cfis commented Sep 3, 2020

Ah. Yeah that doesn't look good. Not sure what would have changed with Ruby 2.7.1 but will take a look.

@cfis
Copy link
Member

cfis commented Sep 4, 2020

Ok, this is a ruby bug. See https://bugs.ruby-lang.org/issues/17152.

@MacksMind
Copy link
Author

Looks like the fix from 3.0 got backported to the 2.7.x trunk. Leave this open for reference until 2.7.2 ships, or ???

@cfis cfis changed the title Odd call stack nesting in Ruby 2.7.1 Odd call stack nesting in Ruby 2.7.0 and 2.7.1 Sep 16, 2020
@cfis
Copy link
Member

cfis commented Sep 16, 2020

I'll update the docs to note this, and then close this ticket. Had a similar problem in an older version of Ruby. Thanks for finding this!

@MacksMind
Copy link
Author

Verified that Ruby 2.7.2 resolves the issue.

cfis added a commit to ruby-prof/ruby-prof.github.io that referenced this issue Oct 29, 2020
@cfis
Copy link
Member

cfis commented Oct 29, 2020

Thanks!

Updated documentation in ruby-prof/ruby-prof.github.io@de57d29

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants